Introduce smart fetching, based on type of local repo.

This commit is contained in:
Webber 2020-05-01 14:17:30 +02:00 committed by Webber Takken
parent cd1d215dfa
commit b41026b36e
3 changed files with 10 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -131,10 +131,17 @@ export default class Versioning {
/**
* Retrieves refs from the configured remote.
*
* Fetch unshallow for incomplete repository, but fall back to normal fetch.
*
* Note: `--all` should not be used, and would break fetching for push event.
*/
static async fetch() {
await System.run('git', ['fetch']);
try {
await System.run('git', ['fetch', '--unshallow']);
} catch (error) {
core.warning(error);
await System.run('git', ['fetch']);
}
}
/**

View File

@ -197,6 +197,7 @@ describe('Versioning', () => {
describe('fetch', () => {
it('awaits the command', async () => {
jest.spyOn(core, 'warning').mockImplementation(() => {});
jest.spyOn(System, 'run').mockResolvedValue(null);
await expect(Versioning.fetch()).resolves.not.toThrow();
});