summaryrefslogtreecommitdiffstats
path: root/src/modules/git_commit.rs
diff options
context:
space:
mode:
authornesmyslny <nesmyslny@users.noreply.github.com>2020-02-12 20:56:29 +0100
committerGitHub <noreply@github.com>2020-02-12 14:56:29 -0500
commit0312c7b91e2ada97f5975dbcc1f35cab2d0238fe (patch)
treef0615e29f8d6e8e52f409f80cf3675fff250ac04 /src/modules/git_commit.rs
parenta485fd6896447c0eabd24814b47c45bf7f1a872e (diff)
feat(git_commit): Show the hash of commits when detached HEAD (#738)
Diffstat (limited to 'src/modules/git_commit.rs')
-rw-r--r--src/modules/git_commit.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/modules/git_commit.rs b/src/modules/git_commit.rs
index cacfa3982..36e68913d 100644
--- a/src/modules/git_commit.rs
+++ b/src/modules/git_commit.rs
@@ -9,9 +9,6 @@ use crate::configs::git_commit::GitCommitConfig;
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let mut module = context.new_module("git_commit");
let config = GitCommitConfig::try_load(module.config);
- if config.disabled {
- return None;
- };
module
.get_prefix()
@@ -27,6 +24,11 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let repo_root = repo.root.as_ref()?;
let git_repo = Repository::open(repo_root).ok()?;
+ let is_detached = git_repo.head_detached().ok()?;
+ if config.only_detached && !is_detached {
+ return None;
+ };
+
let git_head = git_repo.head().ok()?;
let head_commit = git_head.peel_to_commit().ok()?;
let commit_oid = head_commit.id();