Skip to content

Commit

Permalink
refactor: simplify sync state
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jul 5, 2020
1 parent 9bdd8b5 commit 2cdd8f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/util/git/index.spec.ts
Expand Up @@ -55,6 +55,7 @@ describe('platform/git', () => {
gitAuthorName: 'test',
gitAuthorEmail: 'test@example.com',
});
await git.syncGit();
});

afterEach(async () => {
Expand Down
5 changes: 2 additions & 3 deletions lib/util/git/index.ts
Expand Up @@ -39,7 +39,6 @@ interface LocalConfig extends StorageConfig {
baseBranchSha: string;
branchExists: Record<string, boolean>;
branchPrefix: string;
syncCompleted: boolean;
}

// istanbul ignore next
Expand Down Expand Up @@ -148,10 +147,9 @@ export async function getSubmodules(): Promise<string[]> {
}

export async function syncGit(): Promise<void> {
if (config.syncCompleted) {
if (git) {
return;
}
config.syncCompleted = true;
logger.debug('Initializing git repository into ' + config.localDir);
const gitHead = join(config.localDir, '.git/HEAD');
let clone = true;
Expand Down Expand Up @@ -237,6 +235,7 @@ export async function syncGit(): Promise<void> {
export async function initRepo(args: StorageConfig): Promise<void> {
config = { ...args } as any;
config.branchExists = {};
git = undefined;
await syncGit();
}

Expand Down

0 comments on commit 2cdd8f4

Please sign in to comment.