Skip to content

Commit 1a494a9

Browse files
committed
support for shallow clones
1 parent 82fbbb2 commit 1a494a9

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ jobs:
4444
- name: Run clippy
4545
run: cargo clippy
4646

47-
- name: Debug
48-
run: "cat .git/HEAD; git cat-file -p a802f89fc823c6c8cf2467c2b7908e1d78e8b755"
4947
- name: Run onefetch
5048
run: cargo run
5149

src/info/repo.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ impl<'a> Repo<'a> {
105105

106106
let mut num_commits = 0;
107107
while let Some(commit_id) = commit_iter.next() {
108-
let commit: git::Commit = commit_id?
109-
.object()
110-
.expect("commit is still present/comes from cache")
111-
.into_commit();
108+
let commit = match commit_id {
109+
Ok(commit_id) => commit_id
110+
.object()
111+
.expect("commit is still present/comes from cache")
112+
.into_commit(),
113+
Err(git::traverse::commit::ancestors::Error::FindExisting { .. }) => break, // assume a shallow clone
114+
Err(err) => return Err(err.into()),
115+
};
116+
112117
{
113118
let commit = commit.decode()?;
114119
if no_merges && commit.parents().take(2).count() > 1 {

0 commit comments

Comments
 (0)