Merge pull request #4 from ATechnoHazard/develop

search: skip uninitialized repos
This commit is contained in:
Harsh Shandilya 2020-10-14 01:51:47 +05:30 committed by GitHub
commit a92431a9d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 1 deletions

56
.github/workflows/check.yml vendored Normal file
View File

@ -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

View File

@ -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")
));
}
};