about summary refs log tree commit diff stats
path: root/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ba/back/src/git_bug/dag/mod.rs')
-rw-r--r--pkgs/by-name/ba/back/src/git_bug/dag/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs b/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
index 9c158a7..3d22b04 100644
--- a/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
+++ b/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
@@ -123,11 +123,23 @@ impl Dag {
     }
 }
 
+/// Check whether `git-bug` has been initialized in this repository
+pub fn is_git_bug(repo: &Repository) -> error::Result<bool> {
+    Ok(repo
+        .refs
+        .iter()?
+        .prefixed(Path::new("refs/bugs/"))
+        .map_err(|err| error::Error::RepoRefsPrefixed { error: err })?
+        .count()
+        > 0)
+}
+
 pub fn issues_from_repository(repo: &Repository) -> error::Result<Vec<Dag>> {
     let dags = repo
         .refs
         .iter()?
-        .prefixed(Path::new("refs/bugs/"))?
+        .prefixed(Path::new("refs/bugs/"))
+        .map_err(|err| error::Error::RepoRefsPrefixed { error: err })?
         .map(|val| {
             let reference = val.expect("All `git-bug` references in 'refs/bugs' should be objects");