From eb3a09de62f364c6abe35eba31c9a94df2ebca74 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 17 Oct 2024 20:04:06 +0100 Subject: [PATCH] feat: jujustu support If the .git directory can't be opened (usually because the `.git` directory is missing) it attempts to find the git repository in the location used by Jujutsu (i.e. `.jj/repo/store/git`). If the Jujutsu git directory doesn't exist, then the origin error is propogated. --- git-cliff-core/src/repo.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/git-cliff-core/src/repo.rs b/git-cliff-core/src/repo.rs index 81a930b996..f8962afe6c 100644 --- a/git-cliff-core/src/repo.rs +++ b/git-cliff-core/src/repo.rs @@ -48,7 +48,15 @@ impl Repository { /// Initializes (opens) the repository. pub fn init(path: PathBuf) -> Result { if path.exists() { - let inner = GitRepository::open(&path)?; + let inner = GitRepository::open(&path).or_else(|err| { + let jujutsu_path = + path.join(".jj").join("repo").join("store").join("git"); + if jujutsu_path.exists() { + GitRepository::open(&jujutsu_path) + } else { + Err(err) + } + })?; let changed_files_cache_path = inner .path() .join(env!("CARGO_PKG_NAME"))