diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e7b220e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Lint + run: cargo clippy -- -D warnings diff --git a/src/config.rs b/src/config.rs index 19df85f..6436b23 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,7 +47,7 @@ impl Config { pub fn get_github_token() -> Result { let (_, token_path, _) = Config::get_paths(); - let token = fs::read_to_string(&token_path)?; + let token = fs::read_to_string(token_path)?; Ok(token) } @@ -94,7 +94,7 @@ impl Config { pub fn get_default_desc() -> Result { let (_, _, default_desc_path) = Config::get_paths(); - let default_desc = fs::read_to_string(&default_desc_path)?; + let default_desc = fs::read_to_string(default_desc_path)?; Ok(default_desc) } diff --git a/src/github.rs b/src/github.rs index 3dad631..df56644 100644 --- a/src/github.rs +++ b/src/github.rs @@ -85,9 +85,9 @@ impl Github { Ok(json["login"].as_str().unwrap().to_string()) } - fn construct_headers(token: &String) -> HeaderMap { + fn construct_headers(token: &str) -> HeaderMap { let mut headers = HeaderMap::new(); - if let Ok(header_value) = HeaderValue::from_str(&format!("Bearer {}", token.as_str())) { + if let Ok(header_value) = HeaderValue::from_str(&format!("Bearer {}", token)) { headers.insert(AUTHORIZATION, header_value); } headers.insert( diff --git a/src/main.rs b/src/main.rs index d7ffa34..0453932 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,10 +39,10 @@ async fn main() { }; return; } - "help" | _ => { + _ => { println!("{}", "Usage".bold()); println!(" snp [command]"); - println!(""); + println!(); println!("{}", "Commands".bold()); println!(" help Display this message."); println!( @@ -64,12 +64,12 @@ async fn main() { }); let config = Config::ask().unwrap_or_else(|e| { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); }); match Config::confirm(&config).unwrap_or_else(|e| { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); }) { true => {} @@ -79,7 +79,7 @@ async fn main() { match Git::create_branch(&config.branch) { Ok(_) => println!("{}", "✔️ Branch created.".green()), Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } }; @@ -87,7 +87,7 @@ async fn main() { match Git::create_commit(&config.pr_name) { Ok(_) => println!("{}", "✔️ Commit created.".green()), Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } }; @@ -95,7 +95,7 @@ async fn main() { match Git::push(&config.branch) { Ok(_) => println!("{}", "✔️ Successfully pushed.".green()), Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } }; @@ -107,7 +107,7 @@ async fn main() { url } Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } }; @@ -115,16 +115,16 @@ async fn main() { let username = match Github::get_username(&gh).await { Ok(username) => username, Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } }; - let pr_number = pr_url.split("/").last().unwrap(); + let pr_number = pr_url.split('/').last().unwrap(); match Github::assign_to_pr(&gh, &username, pr_number).await { Ok(_) => println!("{}", "✔️ Successfully assigned you.".green()), Err(e) => { - eprintln!("{}", e.to_string()); + eprintln!("{}", e); process::exit(1); } };