mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
refactor(git): separate init from sync
This commit is contained in:
parent
7d18476d74
commit
9bdd8b53c3
1 changed files with 12 additions and 4 deletions
|
@ -39,6 +39,7 @@ interface LocalConfig extends StorageConfig {
|
||||||
baseBranchSha: string;
|
baseBranchSha: string;
|
||||||
branchExists: Record<string, boolean>;
|
branchExists: Record<string, boolean>;
|
||||||
branchPrefix: string;
|
branchPrefix: string;
|
||||||
|
syncCompleted: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
|
@ -146,10 +147,11 @@ export async function getSubmodules(): Promise<string[]> {
|
||||||
.filter((_e: string, i: number) => i % 2);
|
.filter((_e: string, i: number) => i % 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initRepo(args: StorageConfig): Promise<void> {
|
export async function syncGit(): Promise<void> {
|
||||||
config = { ...args } as any;
|
if (config.syncCompleted) {
|
||||||
|
return;
|
||||||
config.branchExists = {};
|
}
|
||||||
|
config.syncCompleted = true;
|
||||||
logger.debug('Initializing git repository into ' + config.localDir);
|
logger.debug('Initializing git repository into ' + config.localDir);
|
||||||
const gitHead = join(config.localDir, '.git/HEAD');
|
const gitHead = join(config.localDir, '.git/HEAD');
|
||||||
let clone = true;
|
let clone = true;
|
||||||
|
@ -232,6 +234,12 @@ export async function initRepo(args: StorageConfig): Promise<void> {
|
||||||
config.baseBranch = config.baseBranch || (await getDefaultBranch(git));
|
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
|
// istanbul ignore next
|
||||||
export async function getRepoStatus(): Promise<StatusResult> {
|
export async function getRepoStatus(): Promise<StatusResult> {
|
||||||
return git.status();
|
return git.status();
|
||||||
|
|
Loading…
Reference in a new issue