Pārlūkot izejas kodu

Fixes hang in shortlog when no HEAD

main
Eric Amodio pirms 4 gadiem
vecāks
revīzija
1e716f0808
3 mainītis faili ar 25 papildinājumiem un 16 dzēšanām
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -1
      src/git/git.ts
  3. +23
    -15
      src/git/gitService.ts

+ 1
- 0
CHANGELOG.md Parādīt failu

@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#1212](https://github.com/eamodio/vscode-gitlens/issues/1212) - Stashes list doesn't refresh on deletion
- Fixes [#1191](https://github.com/eamodio/vscode-gitlens/issues/1191) - "Gitlens › Views › Repositories: Auto Refresh" not working
- Fixes [#1202](https://github.com/eamodio/vscode-gitlens/issues/1202) - "Copy Remote File Url" url-encodes the URL
- Fixes an issue where `git shortlog` could hang (when there is no HEAD)
- Fixes an issue where _GitLens: Show Repositories View_ command wouldn't work unless the view was enabled first
- Fixes an issue where _GitLens: Show Line History View_ command wasn't showing up unless the view was enabled first
- Fixes an issue where trying to force push the current branch would fail

+ 1
- 1
src/git/git.ts Parādīt failu

@ -1168,7 +1168,7 @@ export namespace Git {
}
export function shortlog(repoPath: string) {
return git<string>({ cwd: repoPath }, 'shortlog', '-sne', '--all', '--no-merges');
return git<string>({ cwd: repoPath }, 'shortlog', '-sne', '--all', '--no-merges', 'HEAD');
}
export async function show<TOut extends string | Buffer>(

+ 23
- 15
src/git/gitService.ts Parādīt failu

@ -1391,23 +1391,31 @@ export class GitService implements Disposable {
async getContributors(repoPath: string): Promise<GitContributor[]> {
if (repoPath == null) return [];
const data = await Git.shortlog(repoPath);
const shortlog = GitShortLogParser.parse(data, repoPath);
if (shortlog == null) return [];
// Mark the current user
const currentUser = await Container.git.getCurrentUser(repoPath);
if (currentUser != null) {
const index = shortlog.contributors.findIndex(
c => currentUser.email === c.email && currentUser.name === c.name,
);
if (index !== -1) {
const c = shortlog.contributors[index];
shortlog.contributors.splice(index, 1, new GitContributor(c.repoPath, c.name, c.email, c.count, true));
try {
const data = await Git.shortlog(repoPath);
const shortlog = GitShortLogParser.parse(data, repoPath);
if (shortlog == null) return [];
// Mark the current user
const currentUser = await Container.git.getCurrentUser(repoPath);
if (currentUser != null) {
const index = shortlog.contributors.findIndex(
c => currentUser.email === c.email && currentUser.name === c.name,
);
if (index !== -1) {
const c = shortlog.contributors[index];
shortlog.contributors.splice(
index,
1,
new GitContributor(c.repoPath, c.name, c.email, c.count, true),
);
}
}
}
return shortlog.contributors;
return shortlog.contributors;
} catch (ex) {
return [];
}
}
@log()

Notiek ielāde…
Atcelt
Saglabāt