Browse Source

Adds paging support for `log --all`

Co-authored-by: Ramin Tadayon <ramin.tadayon@gitkraken.com>
main
Eric Amodio 2 years ago
parent
commit
d445c7ca4d
2 changed files with 23 additions and 4 deletions
  1. +7
    -1
      src/env/node/git/git.ts
  2. +16
    -3
      src/env/node/git/localGitProvider.ts

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

@ -698,6 +698,7 @@ export class Git {
ordering,
similarityThreshold,
since,
until,
}: {
all?: boolean;
argsOrFormat?: string | string[];
@ -706,7 +707,8 @@ export class Git {
merges?: boolean;
ordering?: string | null;
similarityThreshold?: number | null;
since?: string;
since?: number | string;
until?: number | string;
},
) {
if (argsOrFormat == null) {
@ -737,6 +739,10 @@ export class Git {
params.push(`--since="${since}"`);
}
if (until) {
params.push(`--until="${until}"`);
}
if (!merges) {
params.push('--first-parent');
}

+ 16
- 3
src/env/node/git/localGitProvider.ts View File

@ -2068,7 +2068,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
merges?: boolean;
ordering?: string | null;
ref?: string;
since?: string;
since?: number | string;
until?: number | string;
},
): Promise<GitLog | undefined> {
const scope = getLogScope();
@ -2183,6 +2184,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
private getLogMoreFn(
log: GitLog,
options?: {
all?: boolean;
authors?: GitUser[];
limit?: number;
merges?: boolean;
@ -2212,11 +2214,22 @@ export class LocalGitProvider implements GitProvider, Disposable {
return moreLog;
}
const ref = last(log.commits.values())?.ref;
const lastCommit = last(log.commits.values());
const ref = lastCommit?.ref;
// If we were asked for all refs, use the last commit timestamp (plus a second) as a cursor
let timestamp: number | undefined;
if (options?.all) {
const date = lastCommit?.committer.date;
// Git only allows 1-second precision, so round up to the nearest second
timestamp = date != null ? Math.ceil(date.getTime() / 1000) + 1 : undefined;
}
const moreLog = await this.getLog(log.repoPath, {
...options,
limit: moreUntil == null ? moreLimit : 0,
ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^`,
...(timestamp
? { until: timestamp }
: { ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^` }),
});
// If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };

||||||
x
 
000:0
Loading…
Cancel
Save