Browse Source

Avoids setting more fn if not needed

main
Eric Amodio 2 years ago
parent
commit
04600e8734
2 changed files with 31 additions and 18 deletions
  1. +17
    -9
      src/env/node/git/localGitProvider.ts
  2. +14
    -9
      src/plus/github/githubGitProvider.ts

+ 17
- 9
src/env/node/git/localGitProvider.ts View File

@ -2395,7 +2395,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
limit: moreLimit === 0 ? 0 : (options?.limit ?? 0) + moreLimit, limit: moreLimit === 0 ? 0 : (options?.limit ?? 0) + moreLimit,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
return moreLog; return moreLog;
} }
@ -2418,7 +2418,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
: { ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^` }), : { ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^` }),
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -2441,7 +2441,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
}, },
query: (limit: number | undefined) => this.getLog(log.repoPath, { ...options, limit: limit }), query: (limit: number | undefined) => this.getLog(log.repoPath, { ...options, limit: limit }),
}; };
mergedLog.more = this.getLogMoreFn(mergedLog, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogMoreFn(mergedLog, options);
}
return mergedLog; return mergedLog;
}; };
@ -2583,7 +2585,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
skip: log.count, skip: log.count,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -2598,7 +2600,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
query: (limit: number | undefined) => query: (limit: number | undefined) =>
this.getLogForSearch(log.repoPath, search, { ...options, limit: limit }), this.getLogForSearch(log.repoPath, search, { ...options, limit: limit }),
}; };
mergedLog.more = this.getLogForSearchMoreFn(mergedLog, search, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogForSearchMoreFn(mergedLog, search, options);
}
return mergedLog; return mergedLog;
}; };
@ -2871,7 +2875,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
skip: options.all ? log.count : undefined, skip: options.all ? log.count : undefined,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -2895,7 +2899,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
relativePath = renamed?.file?.originalPath ?? relativePath; relativePath = renamed?.file?.originalPath ?? relativePath;
} }
mergedLog.more = this.getLogForFileMoreFn(mergedLog, relativePath, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogForFileMoreFn(mergedLog, relativePath, options);
}
return mergedLog; return mergedLog;
}; };
@ -3442,7 +3448,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
}); });
if (moreLog == null) { if (moreLog == null) {
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
return { ...reflog, hasMore: false };
return { ...reflog, hasMore: false, more: undefined };
} }
const mergedLog: GitReflog = { const mergedLog: GitReflog = {
@ -3453,7 +3459,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
limit: (reflog.limit ?? 0) + limit, limit: (reflog.limit ?? 0) + limit,
hasMore: moreLog.hasMore, hasMore: moreLog.hasMore,
}; };
mergedLog.more = this.getReflogMoreFn(mergedLog, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getReflogMoreFn(mergedLog, options);
}
return mergedLog; return mergedLog;
}; };

+ 14
- 9
src/plus/github/githubGitProvider.ts View File

@ -1471,7 +1471,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
// limit: moreLimit === 0 ? 0 : (options?.limit ?? 0) + moreLimit, // limit: moreLimit === 0 ? 0 : (options?.limit ?? 0) + moreLimit,
// }); // });
// // If we can't find any more, assume we have everything // // If we can't find any more, assume we have everything
// if (moreLog == null) return { ...log, hasMore: false };
// if (moreLog == null) return { ...log, hasMore: false, more: undefined };
// return moreLog; // return moreLog;
// } // }
@ -1483,7 +1483,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
// ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^`, // ref: moreUntil == null ? `${ref}^` : `${moreUntil}^..${ref}^`,
// }); // });
// // If we can't find any more, assume we have everything // // If we can't find any more, assume we have everything
// if (moreLog == null) return { ...log, hasMore: false };
// if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const moreLog = await this.getLog(log.repoPath, { const moreLog = await this.getLog(log.repoPath, {
...options, ...options,
@ -1491,7 +1491,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
cursor: log.endingCursor, cursor: log.endingCursor,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -1514,7 +1514,9 @@ export class GitHubGitProvider implements GitProvider, Disposable {
}, },
query: log.query, query: log.query,
}; };
mergedLog.more = this.getLogMoreFn(mergedLog, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogMoreFn(mergedLog, options);
}
return mergedLog; return mergedLog;
}; };
@ -1688,7 +1690,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
cursor: log.endingCursor, cursor: log.endingCursor,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -1703,7 +1705,9 @@ export class GitHubGitProvider implements GitProvider, Disposable {
endingCursor: moreLog.endingCursor, endingCursor: moreLog.endingCursor,
query: log.query, query: log.query,
}; };
mergedLog.more = this.getLogForSearchMoreFn(mergedLog, search, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogForSearchMoreFn(mergedLog, search, options);
}
return mergedLog; return mergedLog;
}; };
@ -1984,7 +1988,6 @@ export class GitHubGitProvider implements GitProvider, Disposable {
endingCursor: result.paging?.cursor, endingCursor: result.paging?.cursor,
query: (limit: number | undefined) => this.getLogForFile(repoPath, path, { ...options, limit: limit }), query: (limit: number | undefined) => this.getLogForFile(repoPath, path, { ...options, limit: limit }),
}; };
if (log.hasMore) { if (log.hasMore) {
log.more = this.getLogForFileMoreFn(log, path, options); log.more = this.getLogForFileMoreFn(log, path, options);
} }
@ -2042,7 +2045,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
// skip: options.all ? log.count : undefined, // skip: options.all ? log.count : undefined,
}); });
// If we can't find any more, assume we have everything // If we can't find any more, assume we have everything
if (moreLog == null) return { ...log, hasMore: false };
if (moreLog == null) return { ...log, hasMore: false, more: undefined };
const commits = new Map([...log.commits, ...moreLog.commits]); const commits = new Map([...log.commits, ...moreLog.commits]);
@ -2066,7 +2069,9 @@ export class GitHubGitProvider implements GitProvider, Disposable {
// fileName = renamed?.file?.originalPath ?? fileName; // fileName = renamed?.file?.originalPath ?? fileName;
// } // }
mergedLog.more = this.getLogForFileMoreFn(mergedLog, relativePath, options);
if (mergedLog.hasMore) {
mergedLog.more = this.getLogForFileMoreFn(mergedLog, relativePath, options);
}
return mergedLog; return mergedLog;
}; };

Loading…
Cancel
Save