Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pristine in branchCache (#18478)
- Loading branch information
1 parent
516b56e
commit 987421b
Showing
15 changed files
with
78 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { mocked, partial } from '../../../test/util'; | ||
import * as _repositoryCache from '../cache/repository'; | ||
import type { BranchCache, RepoCacheData } from '../cache/repository/types'; | ||
import { getCachedPristineResult } from './pristine'; | ||
|
||
jest.mock('../cache/repository'); | ||
const repositoryCache = mocked(_repositoryCache); | ||
|
||
describe('util/git/pristine', () => { | ||
let repoCache: RepoCacheData = {}; | ||
|
||
beforeEach(() => { | ||
repoCache = {}; | ||
repositoryCache.getCache.mockReturnValue(repoCache); | ||
}); | ||
|
||
describe('getCachedPristineResult', () => { | ||
it('returns false if cache is not populated', () => { | ||
expect(getCachedPristineResult('foo')).toBeFalse(); | ||
}); | ||
|
||
it('returns false if branch not found', () => { | ||
repoCache.branches = [partial<BranchCache>({ branchName: 'not_foo' })]; | ||
expect(getCachedPristineResult('foo')).toBeFalse(); | ||
}); | ||
|
||
it('returns true', () => { | ||
repoCache.branches = [ | ||
partial<BranchCache>({ | ||
branchName: 'foo', | ||
pristine: true, | ||
}), | ||
]; | ||
expect(getCachedPristineResult('foo')).toBeTrue(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { getCache } from '../cache/repository'; | ||
|
||
export function getCachedPristineResult(branchName: string): boolean { | ||
const cache = getCache(); | ||
const branch = cache.branches?.find( | ||
(branch) => branch.branchName === branchName | ||
); | ||
|
||
return branch?.pristine ?? false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.