summaryrefslogtreecommitdiffstats
path: root/src/modules/git_commit.rs
diff options
context:
space:
mode:
authorDavid Knaack <davidkna@users.noreply.github.com>2022-08-19 08:27:41 +0200
committerGitHub <noreply@github.com>2022-08-19 08:27:41 +0200
commit5984f0829ef5369e83c28108378fe0065a617b3c (patch)
tree1926327c8ea203f435d17ebab8de1db9ea42ece0 /src/modules/git_commit.rs
parent56f8c0be7c679a4bcf61904ae438e5a66cca79d1 (diff)
perf(git_commit): only use exact match for tag by default (#4281)
Diffstat (limited to 'src/modules/git_commit.rs')
-rw-r--r--src/modules/git_commit.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/git_commit.rs b/src/modules/git_commit.rs
index 88ab069aa..60f8793ea 100644
--- a/src/modules/git_commit.rs
+++ b/src/modules/git_commit.rs
@@ -32,7 +32,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
"tag" => Some(Ok(format!(
"{}{}",
config.tag_symbol,
- git_tag(context.get_repo().ok()?)?
+ git_tag(context.get_repo().ok()?, &config)?
))),
_ => None,
})
@@ -50,13 +50,17 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(module)
}
-fn git_tag(repo: &Repo) -> Option<String> {
+fn git_tag(repo: &Repo, config: &GitCommitConfig) -> Option<String> {
// allow environment variables like GITOXIDE_OBJECT_CACHE_MEMORY and GITOXIDE_DISABLE_PACK_CACHE to speed up operation for some repos
let mut git_repo = repo.open().apply_environment();
git_repo.object_cache_size_if_unset(4 * 1024 * 1024);
let head_commit = git_repo.head_commit().ok()?;
- let describe_platform = head_commit.describe().names(AnnotatedTags);
+ let describe_platform = head_commit
+ .describe()
+ .names(AnnotatedTags)
+ .max_candidates(config.tag_max_candidates)
+ .traverse_first_parent(true);
let formatter = describe_platform.try_format().ok()??;
Some(formatter.name?.to_string())