Parcourir la source

Closes #388 - Adds git mailmap support

main
Eric Amodio il y a 6 ans
Parent
révision
6565951e81
3 fichiers modifiés avec 18 ajouts et 3 suppressions
  1. +1
    -1
      CHANGELOG.md
  2. +6
    -2
      src/git/git.ts
  3. +11
    -0
      src/gitService.ts

+ 1
- 1
CHANGELOG.md Voir le fichier

@ -25,7 +25,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#405](https://github.com/eamodio/vscode-gitlens/issues/405) - Secondary, blank repository appears repeatedly in gitExplorer view
- Fixes [#430](https://github.com/eamodio/vscode-gitlens/issues/430) - File revisions can end up being parsed by language servers (causing errors and warnings, etc)
- Fixes issues with git log caching
- Fixes [#388](https://github.com/eamodio/vscode-gitlens/issues/388) - Support the mailmap feature of git
### Removed

+ 6
- 2
src/git/git.ts Voir le fichier

@ -23,8 +23,8 @@ const sl = '%x2f'; // `%x${'/'.charCodeAt(0).toString(16)}`;
const logFormat = [
`${lb}${sl}f${rb}`,
`${lb}r${rb} %H`, // ref
`${lb}a${rb} %an`, // author
`${lb}e${rb} %ae`, // email
`${lb}a${rb} %aN`, // author
`${lb}e${rb} %aE`, // email
`${lb}d${rb} %at`, // date
`${lb}p${rb} %P`, // parents
`${lb}s${rb}`,
@ -384,6 +384,10 @@ export class Git {
return git({ cwd: repoPath }, ...params, ref);
}
static check_mailmap(repoPath: string, author: string) {
return git({ cwd: repoPath }, 'check-mailmap', author);
}
static checkout(repoPath: string, fileName: string, sha: string) {
const [file, root] = Git.splitPath(fileName, repoPath);

+ 11
- 0
src/gitService.ts Voir le fichier

@ -69,6 +69,7 @@ const RepoSearchWarnings = {
};
const userConfigRegex = /^user\.(name|email) (.*)$/gm;
const mappedAuthorRegex = /(.+)\s<(.+)>/;
export enum GitRepoSearchBy {
Author = 'author',
@ -950,6 +951,16 @@ export class GitService implements Disposable {
user[match[1] as 'name' | 'email'] = (' ' + match[2]).substr(1);
} while (match != null);
const author = `${user.name} <${user.email}>`;
// Check if there is a mailmap for the current user
const mappedAuthor = await Git.check_mailmap(repoPath, author);
if (author !== mappedAuthor) {
match = mappedAuthorRegex.exec(mappedAuthor);
if (match != null) {
[, user.name, user.email] = match;
}
}
this._userMapCache.set(repoPath, user);
return user;
}

Chargement…
Annuler
Enregistrer