From bcaabf5c5cccc733ebea4d2c7db1f2cc5e022b22 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sat, 13 Jul 2019 10:40:12 +0200 Subject: [PATCH] chore: log branchName with git errors --- lib/platform/git/storage.ts | 11 ++++++++--- test/platform/git/__snapshots__/storage.spec.ts.snap | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index 50ae414d90..cd53c9d9ab 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -169,7 +169,9 @@ export class Storage { // Return the commit SHA for a branch async getBranchCommit(branchName: string) { if (!(await this.branchExists(branchName))) { - throw Error('Cannot fetch commit for branch that does not exist'); + throw Error( + 'Cannot fetch commit for branch that does not exist: ' + branchName + ); } const res = await this._git!.revparse(['origin/' + branchName]); return res.trim(); @@ -188,7 +190,8 @@ export class Storage { if (branchName) { if (!(await this.branchExists(branchName))) { throw new Error( - 'Cannot set baseBranch to something that does not exist' + 'Cannot set baseBranch to something that does not exist: ' + + branchName ); } logger.debug(`Setting baseBranch to ${branchName}`); @@ -293,7 +296,9 @@ export class Storage { async isBranchStale(branchName: string) { if (!(await this.branchExists(branchName))) { - throw Error('Cannot check staleness for branch that does not exist'); + throw Error( + 'Cannot check staleness for branch that does not exist: ' + branchName + ); } const branches = await this._git!.branch([ '--remotes', diff --git a/test/platform/git/__snapshots__/storage.spec.ts.snap b/test/platform/git/__snapshots__/storage.spec.ts.snap index 0017cdca09..1f6cdc925e 100644 --- a/test/platform/git/__snapshots__/storage.spec.ts.snap +++ b/test/platform/git/__snapshots__/storage.spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`platform/git/storage getBranchCommit(branchName) should throw if branch does not exist 1`] = `[Error: Cannot fetch commit for branch that does not exist]`; +exports[`platform/git/storage getBranchCommit(branchName) should throw if branch does not exist 1`] = `[Error: Cannot fetch commit for branch that does not exist: not_found]`; exports[`platform/git/storage getCommitMessages() returns commit messages 1`] = ` Array [ @@ -42,6 +42,6 @@ Array [ ] `; -exports[`platform/git/storage isBranchStale() should throw if branch does not exist 1`] = `[Error: Cannot check staleness for branch that does not exist]`; +exports[`platform/git/storage isBranchStale() should throw if branch does not exist 1`] = `[Error: Cannot check staleness for branch that does not exist: not_found]`; -exports[`platform/git/storage setBaseBranch(branchName) should throw if branch does not exist 1`] = `[Error: Cannot set baseBranch to something that does not exist]`; +exports[`platform/git/storage setBaseBranch(branchName) should throw if branch does not exist 1`] = `[Error: Cannot set baseBranch to something that does not exist: not_found]`; -- GitLab