SCM - add caching layer to incoming/outgoing tree nodes (#198306)

* Upstream commit + improve onDidChangeCurrentHistoryItemGroup

* Refactor expanding a history item group

* Wire up caching

* Invoking the git.refresh command invalidates the cache

* Clean up cache data structure
This commit is contained in:
Ladislau Szomoru
2023-11-15 15:09:18 +01:00
committed by GitHub
parent 43b0558cc1
commit e0b70e58b3
11 changed files with 181 additions and 72 deletions

View File

@@ -2193,6 +2193,13 @@ export class Repository {
if (HEAD.name) {
// Branch
HEAD = await this.getBranch(HEAD.name);
// Upstream commit
if (HEAD && HEAD.upstream) {
const ref = `refs/remotes/${HEAD.upstream.remote}/${HEAD.upstream.name}`;
const commit = await this.revParse(ref);
HEAD = { ...HEAD, upstream: { ...HEAD.upstream, commit } };
}
} else if (HEAD.commit) {
// Tag || Commit
const tags = await this.getRefs({ pattern: 'refs/tags' });
@@ -2596,6 +2603,13 @@ export class Repository {
}
async revParse(ref: string): Promise<string | undefined> {
try {
const result = await fs.readFile(path.join(this.dotGit.path, ref), 'utf8');
return result.trim();
} catch (err) {
this.logger.warn(err.message);
}
try {
const result = await this.exec(['rev-parse', ref]);
if (result.stderr) {