diff --git a/lib/platform/git/storage.js b/lib/platform/git/storage.js index 754065eef5cfb24dd194a89c8081cd15506a3657..73e8f019e4954c0a9681b55f82daabe32f442e17 100644 --- a/lib/platform/git/storage.js +++ b/lib/platform/git/storage.js @@ -40,6 +40,14 @@ class Storage { ); const gitHead = path.join(repoDir, '.git/HEAD'); let clone = true; + async function determineBaseBranch() { + // see https://stackoverflow.com/a/44750379/1438522 + config.baseBranch = + config.baseBranch || + (await git.raw(['symbolic-ref', 'refs/remotes/origin/HEAD'])) + .replace('refs/remotes/origin/', '') + .trim(); + } // istanbul ignore if if (process.env.NODE_ENV !== 'test' && (await fs.exists(gitHead))) { try { @@ -75,12 +83,7 @@ class Storage { await git.raw(['config', 'commit.gpgsign', 'false']); } - // see https://stackoverflow.com/a/44750379/1438522 - config.baseBranch = - config.baseBranch || - (await git.raw(['symbolic-ref', 'refs/remotes/origin/HEAD'])) - .replace('refs/remotes/origin/', '') - .trim(); + await determineBaseBranch(); } async function createBranch(branchName, sha) {