diff --git a/helix-vcs/src/git/blame.rs b/helix-vcs/src/git/blame.rs index 63b52a36d..c12e1e9cb 100644 --- a/helix-vcs/src/git/blame.rs +++ b/helix-vcs/src/git/blame.rs @@ -61,15 +61,33 @@ impl FileBlame { }; let message = commit.as_ref().and_then(|c| c.message().ok()); - let author = commit.as_ref().and_then(|c| c.author().ok()); - let time = author.and_then(|a| a.time.parse::().ok()); + + let commit_author = commit.as_ref().and_then(|c| c.author().ok()); + + // NOTE: Repo author is not the person who created the repository, + // but it is the person who is using Helix right now. + // + // If the person who is using Helix made the commit, (they have the same name), + // then instead of using the name, use "You". + let repo_author = repo + .author() + .transpose() + .ok() + .flatten() + .is_some_and(|author| { + commit_author.is_some_and(|commit_author| author.name == commit_author.name) + }) + .then(|| "You".to_string()); + let author_name = + repo_author.or_else(|| commit_author.map(|author| author.name.to_string())); + let time = commit_author.and_then(|a| a.time.parse::().ok()); let line_blame = LineBlame { commit_hash: commit .as_ref() .and_then(|c| c.short_id().map(|id| id.to_string()).ok()), - author_name: author.map(|a| a.name.to_string()), - author_email: author.map(|a| a.email.to_string()), + author_name, + author_email: commit_author.map(|a| a.email.to_string()), commit_date: time.map(|time| time.format(gix::date::time::format::SHORT)), commit_title: message.as_ref().map(|msg| msg.title.to_string()), commit_body: message