Skip to content

Commit 41cb919

Browse files
committed
feat: if you are the author, use "You" instead of name
1 parent 100ad75 commit 41cb919

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

helix-vcs/src/git/blame.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,33 @@ impl FileBlame {
6161
};
6262

6363
let message = commit.as_ref().and_then(|c| c.message().ok());
64-
let author = commit.as_ref().and_then(|c| c.author().ok());
65-
let time = author.and_then(|a| a.time.parse::<gix::date::Time>().ok());
64+
65+
let commit_author = commit.as_ref().and_then(|c| c.author().ok());
66+
67+
// NOTE: Repo author is not the person who created the repository,
68+
// but it is the person who is using Helix right now.
69+
//
70+
// If the person who is using Helix made the commit, (they have the same name),
71+
// then instead of using the name, use "You".
72+
let repo_author = repo
73+
.author()
74+
.transpose()
75+
.ok()
76+
.flatten()
77+
.is_some_and(|author| {
78+
commit_author.is_some_and(|commit_author| author.name == commit_author.name)
79+
})
80+
.then(|| "You".to_string());
81+
let author_name =
82+
repo_author.or_else(|| commit_author.map(|author| author.name.to_string()));
83+
let time = commit_author.and_then(|a| a.time.parse::<gix::date::Time>().ok());
6684

6785
let line_blame = LineBlame {
6886
commit_hash: commit
6987
.as_ref()
7088
.and_then(|c| c.short_id().map(|id| id.to_string()).ok()),
71-
author_name: author.map(|a| a.name.to_string()),
72-
author_email: author.map(|a| a.email.to_string()),
89+
author_name,
90+
author_email: commit_author.map(|a| a.email.to_string()),
7391
commit_date: time.map(|time| time.format(gix::date::time::format::SHORT)),
7492
commit_title: message.as_ref().map(|msg| msg.title.to_string()),
7593
commit_body: message

0 commit comments

Comments
 (0)