From 79b73ee75ca0c2b47379995caf03edcf0bdb7053 Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 22:35:02 +0200 Subject: [PATCH 1/6] Add CI workflow for linting and tests --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..befe15d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +on: push + +name: CI + +jobs: + lint_and_test: + name: lint and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy, rustfmt + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features -- -D warnings + - run: cargo check --workspace --all-features + - run: cargo test --all-targets + - run: cargo fmt --all -- --check From a97e37a9f38838fee06d418f7096d5f919532df9 Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 22:44:27 +0200 Subject: [PATCH 2/6] Use &str instead of &String We don't need a new object here, a slice is fine. --- src/bin/git-mob.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/git-mob.rs b/src/bin/git-mob.rs index aa9a39b..6ed45be 100644 --- a/src/bin/git-mob.rs +++ b/src/bin/git-mob.rs @@ -40,7 +40,7 @@ fn list_coauthors() { } } -fn override_main_author(initials: &String) { +fn override_main_author(initials: &str) { let all_authors = get_available_coauthors(); match all_authors.get(initials) { Some(new_main_author) => set_main_author(&new_main_author), From 9d09b31602a57d63c8d36021d3032f1ff18a3652 Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 22:54:32 +0200 Subject: [PATCH 3/6] Fix needless-borrow --- src/bin/git-mob.rs | 4 ++-- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/git-mob.rs b/src/bin/git-mob.rs index 6ed45be..2ff9a5f 100644 --- a/src/bin/git-mob.rs +++ b/src/bin/git-mob.rs @@ -43,7 +43,7 @@ fn list_coauthors() { fn override_main_author(initials: &str) { let all_authors = get_available_coauthors(); match all_authors.get(initials) { - Some(new_main_author) => set_main_author(&new_main_author), + Some(new_main_author) => set_main_author(new_main_author), None => { eprintln!("Error: author with initials {} not found", initials); process::exit(1); @@ -52,7 +52,7 @@ fn override_main_author(initials: &str) { } fn write_coauthors_to_gitmessage_file(coauthor_initials: &[String]) { - let coauthors = select_coauthors(&coauthor_initials); + let coauthors = select_coauthors(coauthor_initials); let mut content = String::from("\n\n"); for author in &coauthors { content.push_str(&format!("Co-authored-by: {}\n", &author.to_string())); diff --git a/src/lib.rs b/src/lib.rs index 11020e9..b7c2c12 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,7 @@ pub fn ensure_commit_template_is_set() { with_git_repo_or_exit(|repo| { let mut config = repo.config().unwrap(); config - .set_str("commit.template", &".git/.gitmessage") + .set_str("commit.template", ".git/.gitmessage") .unwrap(); }) } From fe1c91cfa58efc80b74f7a12c64f534a388e13ec Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 23:12:51 +0200 Subject: [PATCH 4/6] Fix format --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b7c2c12..e3882a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ impl fmt::Display for Author { pub fn get_main_author() -> Author { let cfg = match Repository::open_from_env() { Ok(repo) => repo.config().unwrap(), - Err(_e) => Config::open_default().unwrap() + Err(_e) => Config::open_default().unwrap(), }; let name = cfg.get_entry("user.name").unwrap(); From 4061981c4bfd5b87990ee42750836c44f91f4ca0 Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 23:18:51 +0200 Subject: [PATCH 5/6] Build artifacts when on main This makes it easier for everyone to install git-mob and friends, since they don't have to compile it themselves anymore. --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index befe15d..f7b9144 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,26 @@ jobs: - run: cargo check --workspace --all-features - run: cargo test --all-targets - run: cargo fmt --all -- --check + + build_package: + needs: lint_and_test + if: github.ref == 'refs/heads/main' + name: Build package + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: cargo build --release + - uses: actions/upload-artifact@v2 + with: + name: git-mob-${{ matrix.os }} + path: | + target/release/git-* + !target/release/*.d From b5757b3feb1ca15bf88085c17af3ba280bb33e6e Mon Sep 17 00:00:00 2001 From: Martin Frost Date: Wed, 18 Aug 2021 23:17:14 +0200 Subject: [PATCH 6/6] Remove TravisCI config --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8c91a74..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -matrix: - allow_failures: - - rust: nightly