Browse Source

"Fixes" missing stashes from Graph

There has to be a better way to do this
main
Eric Amodio 2 years ago
parent
commit
d3db970bfe
2 changed files with 35 additions and 9 deletions
  1. +6
    -2
      src/env/node/git/git.ts
  2. +29
    -7
      src/env/node/git/localGitProvider.ts

+ 6
- 2
src/env/node/git/git.ts View File

@ -769,15 +769,19 @@ export class Git {
);
}
log2(repoPath: string, ref: string | undefined, ...args: unknown[]) {
log2(repoPath: string, ref: string | undefined, stdin: string | undefined, ...args: unknown[]) {
const params = ['log', ...args];
if (ref && !GitRevision.isUncommittedStaged(ref)) {
params.push(ref);
}
if (stdin) {
params.push('--stdin');
}
return this.git<string>(
{ cwd: repoPath, configs: ['-c', 'diff.renameLimit=0', '-c', 'log.showSignature=false'] },
{ cwd: repoPath, configs: ['-c', 'diff.renameLimit=0', '-c', 'log.showSignature=false'], stdin: stdin },
...params,
'--',
);

+ 29
- 7
src/env/node/git/localGitProvider.ts View File

@ -110,7 +110,7 @@ import { countStringLength, filterMap } from '../../../system/array';
import { TimedCancellationSource } from '../../../system/cancellation';
import { gate } from '../../../system/decorators/gate';
import { debug, getLogScope, log } from '../../../system/decorators/log';
import { filterMap as filterMapIterable, find, first, last, some } from '../../../system/iterable';
import { filterMap as filterMapIterable, find, first, join, last, map, some } from '../../../system/iterable';
import {
commonBaseIndex,
dirname,
@ -1611,6 +1611,17 @@ export class LocalGitProvider implements GitProvider, Disposable {
): Promise<GitGraph> {
const scope = getLogScope();
let stdin: string | undefined;
// // TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
const stash = await this.getStash(repoPath);
if (stash != null) {
stdin = join(
map(stash.commits.values(), c => c.sha.substring(0, 7)),
'\n',
);
}
let getLogForRefFn;
if (options?.ref != null) {
async function getLogForRef(this: LocalGitProvider): Promise<GitLog | undefined> {
@ -1626,6 +1637,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
ordering: 'date',
limit: 0,
extraArgs: [`--since="${Number(commit.date)}"`, '--boundary'],
stdin: stdin,
});
let found = log?.commits.has(commit.sha) ?? false;
@ -1668,17 +1680,26 @@ export class LocalGitProvider implements GitProvider, Disposable {
}
return (
log ??
this.getLog(repoPath, { all: options?.mode !== 'single', ordering: 'date', limit: options?.limit })
this.getLog(repoPath, {
all: options?.mode !== 'single',
ordering: 'date',
limit: options?.limit,
stdin: stdin,
})
);
}
getLogForRefFn = getLogForRef;
}
const [logResult, stashResult, remotesResult] = await Promise.allSettled([
const [logResult, remotesResult] = await Promise.allSettled([
getLogForRefFn?.call(this) ??
this.getLog(repoPath, { all: options?.mode !== 'single', ordering: 'date', limit: options?.limit }),
this.getStash(repoPath),
this.getLog(repoPath, {
all: options?.mode !== 'single',
ordering: 'date',
limit: options?.limit,
stdin: stdin,
}),
this.getRemotes(repoPath),
]);
@ -1686,7 +1707,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
repoPath,
asWebviewUri,
getSettledValue(logResult),
getSettledValue(stashResult),
stash,
getSettledValue(remotesResult),
options,
);
@ -2326,6 +2347,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
since?: number | string;
until?: number | string;
extraArgs?: string[];
stdin?: string;
},
): Promise<GitLog | undefined> {
const scope = getLogScope();
@ -2386,7 +2408,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
args.push(`-n${limit + 1}`);
}
const data = await this.git.log2(repoPath, options?.ref, ...args);
const data = await this.git.log2(repoPath, options?.ref, options?.stdin, ...args);
// const parser = GitLogParser.defaultParser;

Loading…
Cancel
Save