refactor(git): separate init from sync

This commit is contained in:
Rhys Arkins 2020-07-05 08:25:21 +02:00
parent 7d18476d74
commit 9bdd8b53c3

View file

@ -39,6 +39,7 @@ interface LocalConfig extends StorageConfig {
baseBranchSha: string;
branchExists: Record<string, boolean>;
branchPrefix: string;
syncCompleted: boolean;
}
// istanbul ignore next
@ -146,10 +147,11 @@ export async function getSubmodules(): Promise<string[]> {
.filter((_e: string, i: number) => i % 2);
}
export async function initRepo(args: StorageConfig): Promise<void> {
config = { ...args } as any;
config.branchExists = {};
export async function syncGit(): Promise<void> {
if (config.syncCompleted) {
return;
}
config.syncCompleted = true;
logger.debug('Initializing git repository into ' + config.localDir);
const gitHead = join(config.localDir, '.git/HEAD');
let clone = true;
@ -232,6 +234,12 @@ export async function initRepo(args: StorageConfig): Promise<void> {
config.baseBranch = config.baseBranch || (await getDefaultBranch(git));
}
export async function initRepo(args: StorageConfig): Promise<void> {
config = { ...args } as any;
config.branchExists = {};
await syncGit();
}
// istanbul ignore next
export async function getRepoStatus(): Promise<StatusResult> {
return git.status();