Skip to content

Commit ed3de96

Browse files
committed
Fixes missing committer email in logs
Fixes committer name matching for current user
1 parent beeb30f commit ed3de96

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

src/git/parsers/blameParser.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { GitFileIndexStatus } from '../models/fileStatus';
99
import { uncommitted } from '../models/revision';
1010
import type { GitUser } from '../models/user';
1111
import { isUncommitted } from '../utils/revision.utils';
12+
import { isUserMatch } from '../utils/user.utils';
1213

1314
interface BlameEntry {
1415
sha: string;
@@ -202,20 +203,12 @@ function parseBlameEntry(
202203
commits: Map<string, GitCommit>,
203204
authors: Map<string, GitBlameAuthor>,
204205
lines: GitCommitLine[],
205-
currentUser: { name?: string; email?: string } | undefined,
206+
currentUser: GitUser | undefined,
206207
) {
207208
let commit = commits.get(entry.sha);
208209
if (commit == null) {
209210
if (entry.author != null) {
210-
if (
211-
currentUser != null &&
212-
// Name or e-mail is configured
213-
(currentUser.name != null || currentUser.email != null) &&
214-
// Match on name if configured
215-
(currentUser.name == null || currentUser.name === entry.author) &&
216-
// Match on email if configured
217-
(currentUser.email == null || currentUser.email === entry.authorEmail)
218-
) {
211+
if (isUserMatch(currentUser, entry.author, entry.authorEmail)) {
219212
entry.author = 'You';
220213
}
221214

@@ -229,6 +222,10 @@ function parseBlameEntry(
229222
}
230223
}
231224

225+
if (entry.committer != null && isUserMatch(currentUser, entry.committer, entry.committerEmail)) {
226+
entry.committer = 'You';
227+
}
228+
232229
commit = new GitCommit(
233230
container,
234231
repoPath,

src/git/parsers/logParser.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ export function parseGitLog(
587587
break;
588588

589589
case 109: // 'm': // committer-mail
590-
entry.committedDate = line.substring(4);
590+
entry.committerEmail = line.substring(4);
591591
break;
592592

593593
case 99: // 'c': // committer-date
@@ -844,16 +844,12 @@ function parseLogEntry(
844844
stashes: Map<string, GitStashCommit> | undefined,
845845
): void {
846846
if (commit == null) {
847-
if (entry.author != null) {
848-
if (isUserMatch(currentUser, entry.author, entry.authorEmail)) {
849-
entry.author = 'You';
850-
}
847+
if (entry.author != null && isUserMatch(currentUser, entry.author, entry.authorEmail)) {
848+
entry.author = 'You';
851849
}
852850

853-
if (entry.committer != null) {
854-
if (isUserMatch(currentUser, entry.committer, entry.committerEmail)) {
855-
entry.committer = 'You';
856-
}
851+
if (entry.committer != null && isUserMatch(currentUser, entry.committer, entry.committerEmail)) {
852+
entry.committer = 'You';
857853
}
858854

859855
const originalFileName = entry.originalPath ?? (relativeFileName !== entry.path ? entry.path : undefined);

0 commit comments

Comments
 (0)