From f0da001acba43f725127aea0be769f6283ef80cd Mon Sep 17 00:00:00 2001 From: ATechnoHazard Date: Wed, 14 Oct 2020 01:20:31 +0530 Subject: [PATCH 1/2] github: initial check workflow Signed-off-by: ATechnoHazard --- .github/workflows/check.yml | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..4bbd42a --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,56 @@ +on: + push: + branches: + - develop + pull_request: + +name: Check Rust code +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Rust nightly with rustfmt and clippy + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + components: rustfmt, clippy + + - name: Cache cargo registry and build outputs + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + target + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + + - name: Annotate commit with clippy warnings + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: check + + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + + - name: Run cargo doc + uses: actions-rs/cargo@v1 + with: + command: doc + args: --no-deps \ No newline at end of file From 8d261ee9fd97e9b13cebdaa1cbb8dcddf4a6cbd3 Mon Sep 17 00:00:00 2001 From: ATechnoHazard Date: Wed, 14 Oct 2020 01:46:11 +0530 Subject: [PATCH 2/2] search: skip empty repos Signed-off-by: ATechnoHazard --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3bd9929..5df6857 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,10 +16,15 @@ fn main() -> anyhow::Result<()> { let path = format!("{}/.git", entry.path().display()); let git_dir = Path::new(&path); if git_dir.exists() { + let repo = Repository::open(git_dir)?; + if repo.is_empty()? { + continue; + } + items.push(format!( "{} = {}", entry.path().to_string_lossy().to_string(), - Repository::open(git_dir)?.head()?.name().unwrap_or("None") + repo.head()?.name().unwrap_or("None") )); } };