diff --git a/README.md b/README.md index 8b8e6e34..8bd65172 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,9 @@ The above commands will start an interactive prompt. You can use the `arrow keys | --------------- | ----------------------------------------- | ------------------------ | | --accessToken | Github access token | string | | --all | Show all commits | boolean (default: false) | +| --apiHostname | Hostname for the Github API | string | | --branch | Branch to backport to | string | +| --gitHostname | Hostname for Github | string | | --labels | Pull request labels | string | | --multiple | Backport multiple commits and/or branches | boolean | | --prDescription | Description to be added to pull request | string | diff --git a/docs/configuration.md b/docs/configuration.md index 7fed0187..d586c1ce 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -118,3 +118,23 @@ CLI: `--prTitle "My PR Title"` Text that will be added to the pull request body. CLI: `--prDescription "skip-ci"` + +#### `gitHostname` + +Hostname for Github. + +Example: `github.my-private-company.com` + +Default: `github.com` + +CLI: `--gitHostname "github.my-private-company.com"` + +#### `apiHostname` + +Hostname for the Github API. + +Example: `api.github.my-private-company.com` + +Default: `api.github.com` + +CLI: `--apiHostname "api.github.my-private-company.com"` diff --git a/src/options/cliArgs.ts b/src/options/cliArgs.ts index f9afafec..8dadb5e9 100644 --- a/src/options/cliArgs.ts +++ b/src/options/cliArgs.ts @@ -19,6 +19,11 @@ export function getOptionsFromCliArgs( description: 'List all commits', type: 'boolean' }) + .option('apiHostname', { + default: configOptions.apiHostname, + description: 'Hostname for the Github API', + type: 'string' + }) .option('branches', { default: [] as string[], description: 'Branch(es) to backport to', @@ -26,6 +31,11 @@ export function getOptionsFromCliArgs( alias: 'branch', string: true // ensure `6.0` is not coerced to `6` }) + .option('gitHostname', { + default: configOptions.gitHostname, + description: 'Hostname for Github', + type: 'string' + }) .option('labels', { default: configOptions.labels, description: 'Pull request labels', @@ -78,8 +88,10 @@ export function getOptionsFromCliArgs( return { accessToken: cliArgs.accessToken, all: cliArgs.all, + apiHostname: cliArgs.apiHostname, branchChoices: configOptions.branchChoices, branches: cliArgs.branches, + gitHostname: cliArgs.gitHostname, labels: cliArgs.labels, multiple: cliArgs.multiple, multipleBranches: cliArgs.multipleBranches || cliArgs.multiple, diff --git a/src/options/config/config.ts b/src/options/config/config.ts index 6580ee1a..895c7b18 100644 --- a/src/options/config/config.ts +++ b/src/options/config/config.ts @@ -19,6 +19,8 @@ export async function getOptionsFromConfigFiles() { all: false, labels: [] as string[], prTitle: '[{baseBranch}] {commitMessages}', + gitHostname: 'github.com', + apiHostname: 'api.github.com', // options from config files ...globalConfig, diff --git a/src/options/config/globalConfig.ts b/src/options/config/globalConfig.ts index b2d42e01..81cf2e21 100644 --- a/src/options/config/globalConfig.ts +++ b/src/options/config/globalConfig.ts @@ -10,6 +10,8 @@ interface GlobalConfig { // the following are overwritable by project config: all?: boolean; + apiHostname?: string; + gitHostname?: string; multiple?: boolean; multipleCommits?: boolean; multipleBranches?: boolean; diff --git a/src/options/options.ts b/src/options/options.ts index 328fd92c..dff9126b 100644 --- a/src/options/options.ts +++ b/src/options/options.ts @@ -40,8 +40,10 @@ function getErrorMessage({ export function validateOptions({ accessToken, all, + apiHostname, branchChoices, branches, + gitHostname, labels, multiple, multipleBranches, @@ -79,9 +81,11 @@ export function validateOptions({ return { accessToken, all, + apiHostname, branchChoices, branches, labels, + gitHostname, multiple, multipleBranches, multipleCommits, diff --git a/src/services/git.ts b/src/services/git.ts index 7782980c..869107be 100644 --- a/src/services/git.ts +++ b/src/services/git.ts @@ -42,29 +42,38 @@ export function deleteRepo({ function getRemoteUrl({ owner, repoName, - accessToken + accessToken, + gitHostname }: { owner: string; repoName: string; accessToken: string; + gitHostname: string; }) { - return `https://${accessToken}@github.com/${owner}/${repoName}.git`; + return `https://${accessToken}@${gitHostname}/${owner}/${repoName}.git`; } export function cloneRepo({ owner, repoName, accessToken, - callback + callback, + gitHostname }: { owner: string; repoName: string; accessToken: string; callback: (progress: string) => void; + gitHostname: string; }) { return new Promise((resolve, reject) => { const execProcess = childProcess.exec( - `git clone ${getRemoteUrl({ accessToken, owner, repoName })} --progress`, + `git clone ${getRemoteUrl({ + accessToken, + owner, + repoName, + gitHostname + })} --progress`, { cwd: getRepoOwnerPath(owner), maxBuffer: 100 * 1024 * 1024 }, error => { if (error) { @@ -110,19 +119,22 @@ export async function addRemote({ owner, repoName, username, - accessToken + accessToken, + gitHostname }: { owner: string; repoName: string; username: string; accessToken: string; + gitHostname: string; }) { try { await exec( `git remote add ${username} ${getRemoteUrl({ accessToken, owner: username, - repoName + repoName, + gitHostname })}`, { cwd: getRepoPath(owner, repoName) diff --git a/src/services/github.ts b/src/services/github.ts index e01d0252..a4273237 100644 --- a/src/services/github.ts +++ b/src/services/github.ts @@ -30,7 +30,8 @@ function getCommitMessage(message: string) { export async function fetchCommitsByAuthor( owner: string, repoName: string, - author: string | null + author: string | null, + apiHostname: string ): Promise { const query: GithubQuery = { access_token: accessToken, @@ -44,7 +45,7 @@ export async function fetchCommitsByAuthor( try { const res: AxiosResponse = await axios( - `https://api.github.com/repos/${owner}/${repoName}/commits?${querystring.stringify( + `https://${apiHostname}/repos/${owner}/${repoName}/commits?${querystring.stringify( query )}` ); @@ -54,7 +55,12 @@ export async function fetchCommitsByAuthor( return { message: getCommitMessage(commit.commit.message), sha, - pullNumber: await fetchPullRequestNumberBySha(owner, repoName, sha) + pullNumber: await fetchPullRequestNumberBySha( + owner, + repoName, + sha, + apiHostname + ) }; }); @@ -67,11 +73,12 @@ export async function fetchCommitsByAuthor( export async function fetchCommitBySha( owner: string, repoName: string, - sha: string + sha: string, + apiHostname: string ): Promise { try { const res: AxiosResponse> = await axios( - `https://api.github.com/search/commits?q=hash:${sha}%20repo:${owner}/${repoName}&per_page=1&access_token=${accessToken}`, + `https://${apiHostname}/search/commits?q=hash:${sha}%20repo:${owner}/${repoName}&per_page=1&access_token=${accessToken}`, { headers: { Accept: 'application/vnd.github.cloak-preview' @@ -88,7 +95,8 @@ export async function fetchCommitBySha( const pullNumber = await fetchPullRequestNumberBySha( owner, repoName, - fullSha + fullSha, + apiHostname ); return { @@ -104,11 +112,12 @@ export async function fetchCommitBySha( async function fetchPullRequestNumberBySha( owner: string, repoName: string, - commitSha: string + commitSha: string, + apiHostname: string ): Promise { try { const res: AxiosResponse> = await axios( - `https://api.github.com/search/issues?q=repo:${owner}/${repoName}+${commitSha}+base:master&access_token=${accessToken}` + `https://${apiHostname}/search/issues?q=repo:${owner}/${repoName}+${commitSha}+base:master&access_token=${accessToken}` ); return get(res.data.items[0], 'number'); } catch (e) { @@ -119,11 +128,12 @@ async function fetchPullRequestNumberBySha( export async function createPullRequest( owner: string, repoName: string, - payload: ReturnType + payload: ReturnType, + apiHostname: string ) { try { const res: AxiosResponse = await axios.post( - `https://api.github.com/repos/${owner}/${repoName}/pulls?access_token=${accessToken}`, + `https://${apiHostname}/repos/${owner}/${repoName}/pulls?access_token=${accessToken}`, payload ); return { @@ -139,11 +149,12 @@ export async function addLabelsToPullRequest( owner: string, repoName: string, pullNumber: number, - labels: string[] + labels: string[], + apiHostname: string ) { try { return await axios.post( - `https://api.github.com/repos/${owner}/${repoName}/issues/${pullNumber}/labels?access_token=${accessToken}`, + `https://${apiHostname}/repos/${owner}/${repoName}/issues/${pullNumber}/labels?access_token=${accessToken}`, labels ); } catch (e) { @@ -154,11 +165,12 @@ export async function addLabelsToPullRequest( export async function verifyAccessToken( owner: string, repoName: string, - accessToken: string + accessToken: string, + apiHostname: string ) { try { return await axios.head( - `https://api.github.com/repos/${owner}/${repoName}?access_token=${accessToken}` + `https://${apiHostname}/repos/${owner}/${repoName}?access_token=${accessToken}` ); } catch (e) { const error = e as GithubApiError; @@ -175,7 +187,7 @@ export async function verifyAccessToken( throw new HandledError( `Please check your access token and make sure it is valid` ); - default: + case 404: if (grantedScopes === requiredScopes) { throw new HandledError( `The repository "${owner}/${repoName}" doesn't exist` @@ -185,6 +197,8 @@ export async function verifyAccessToken( throw new HandledError( `You do not have access to the repository "${owner}/${repoName}". Please make sure your access token has the required scopes.\n\nRequired scopes: ${requiredScopes}\nAccess token scopes: ${grantedScopes}` ); + default: + throw e.message; } } } diff --git a/src/steps/doBackportVersions.ts b/src/steps/doBackportVersions.ts index 671c5632..cc4bb54a 100644 --- a/src/steps/doBackportVersions.ts +++ b/src/steps/doBackportVersions.ts @@ -25,7 +25,8 @@ export function doBackportVersions( username: string, labels: string[], prTitle: string, - prDescription: string | undefined + prDescription: string | undefined, + apiHostname: string ) { return sequentially(branches, async branch => { try { @@ -37,7 +38,8 @@ export function doBackportVersions( username, labels, prTitle, - prDescription + prDescription, + apiHostname ); log(`View pull request: ${pullRequest.html_url}`); } catch (e) { @@ -59,7 +61,8 @@ export async function doBackportVersion( username: string, labels: string[] = [], prTitle: string, - prDescription: string | undefined + prDescription: string | undefined, + apiHostname: string ) { const featureBranch = getFeatureBranchName(baseBranch, commits); const refValues = commits.map(commit => getReferenceLong(commit)).join(', '); @@ -98,9 +101,20 @@ export async function doBackportVersion( prTitle, prDescription ); - const pullRequest = await createPullRequest(owner, repoName, payload); + const pullRequest = await createPullRequest( + owner, + repoName, + payload, + apiHostname + ); if (labels.length > 0) { - await addLabelsToPullRequest(owner, repoName, pullRequest.number, labels); + await addLabelsToPullRequest( + owner, + repoName, + pullRequest.number, + labels, + apiHostname + ); } return pullRequest; }); diff --git a/src/steps/getCommits.ts b/src/steps/getCommits.ts index 8389ce16..ad41b1c9 100644 --- a/src/steps/getCommits.ts +++ b/src/steps/getCommits.ts @@ -12,7 +12,9 @@ export async function getCommits(options: BackportOptions) { const [owner, repoName] = options.upstream.split('/'); if (options.sha) { - return [await getCommitBySha(owner, repoName, options.sha)]; + return [ + await getCommitBySha(owner, repoName, options.sha, options.apiHostname) + ]; } const author = options.all ? null : options.username; @@ -20,18 +22,20 @@ export async function getCommits(options: BackportOptions) { owner, repoName, author, - options.multipleCommits + options.multipleCommits, + options.apiHostname ); } export async function getCommitBySha( owner: string, repoName: string, - sha: string + sha: string, + apiHostname: string ) { const spinner = ora(`Loading commit "${getShortSha(sha)}"`).start(); try { - const commit = await fetchCommitBySha(owner, repoName, sha); + const commit = await fetchCommitBySha(owner, repoName, sha, apiHostname); spinner.stop(); return commit; } catch (e) { @@ -44,11 +48,17 @@ async function getCommitsByPrompt( owner: string, repoName: string, author: string | null, - multipleCommits: boolean + multipleCommits: boolean, + apiHostname: string ) { const spinner = ora('Loading commits...').start(); try { - const commits = await fetchCommitsByAuthor(owner, repoName, author); + const commits = await fetchCommitsByAuthor( + owner, + repoName, + author, + apiHostname + ); if (isEmpty(commits)) { const warningText = author ? 'There are no commits by you in this repository' diff --git a/src/steps/maybeSetupRepo.ts b/src/steps/maybeSetupRepo.ts index 34b831ac..ee085609 100644 --- a/src/steps/maybeSetupRepo.ts +++ b/src/steps/maybeSetupRepo.ts @@ -13,12 +13,14 @@ export async function maybeSetupRepo({ accessToken, owner, repoName, - username + username, + gitHostname }: { accessToken: string; owner: string; repoName: string; username: string; + gitHostname: string; }) { const isAlreadyCloned = await repoExists({ owner, repoName }); @@ -36,7 +38,8 @@ export async function maybeSetupRepo({ accessToken, callback: (progress: string) => { spinner.text = `${progress}% ${spinnerCloneText}`; - } + }, + gitHostname }); spinner.succeed(`100% ${spinnerCloneText}`); } catch (e) { @@ -48,10 +51,16 @@ export async function maybeSetupRepo({ // ensure remote are setup with latest accessToken await deleteRemote({ owner, repoName, username }); - await addRemote({ owner, repoName, username, accessToken }); + await addRemote({ owner, repoName, username, accessToken, gitHostname }); if (username !== owner) { await deleteRemote({ owner, repoName, username: owner }); - await addRemote({ owner, repoName, username: owner, accessToken }); + await addRemote({ + owner, + repoName, + username: owner, + accessToken, + gitHostname + }); } } diff --git a/src/steps/steps.ts b/src/steps/steps.ts index 9c144c20..945d45d8 100755 --- a/src/steps/steps.ts +++ b/src/steps/steps.ts @@ -7,7 +7,12 @@ import { maybeSetupRepo } from './maybeSetupRepo'; export async function initSteps(options: BackportOptions) { const [owner, repoName] = options.upstream.split('/'); - await verifyAccessToken(owner, repoName, options.accessToken); + await verifyAccessToken( + owner, + repoName, + options.accessToken, + options.apiHostname + ); setAccessToken(options.accessToken); const commits = await getCommits(options); @@ -17,7 +22,8 @@ export async function initSteps(options: BackportOptions) { owner, repoName, username: options.username, - accessToken: options.accessToken + accessToken: options.accessToken, + gitHostname: options.gitHostname }); await doBackportVersions( owner, @@ -27,6 +33,7 @@ export async function initSteps(options: BackportOptions) { options.username, options.labels, options.prTitle, - options.prDescription + options.prDescription, + options.apiHostname ); } diff --git a/test/options/cliArgs.test.ts b/test/options/cliArgs.test.ts index c233d10b..ea489b01 100644 --- a/test/options/cliArgs.test.ts +++ b/test/options/cliArgs.test.ts @@ -7,7 +7,9 @@ describe('getOptionsFromCliArgs', () => { const configOptions = { accessToken: 'myAccessToken', all: false, + apiHostname: 'api.github.com', branchChoices: [], + gitHostname: 'github.com', labels: [], multiple: false, multipleBranches: true, @@ -38,8 +40,10 @@ describe('getOptionsFromCliArgs', () => { expect(res).toEqual({ accessToken: 'myAccessToken', all: true, + apiHostname: 'api.github.com', branches: ['6.0', '6.1'], branchChoices: [], + gitHostname: 'github.com', labels: [], multiple: false, multipleBranches: true, diff --git a/test/options/config/config.test.ts b/test/options/config/config.test.ts index ece13e75..2282a41c 100644 --- a/test/options/config/config.test.ts +++ b/test/options/config/config.test.ts @@ -32,10 +32,12 @@ describe('getOptionsFromConfigFiles', () => { expect(res).toEqual({ accessToken: 'myAccessToken', all: false, + apiHostname: 'api.github.com', branchChoices: [ { checked: false, name: '6.x' }, { checked: false, name: '6.1' } ], + gitHostname: 'github.com', labels: [], multiple: false, multipleBranches: true, diff --git a/test/options/options.test.ts b/test/options/options.test.ts index aa2b71b8..7b73922e 100644 --- a/test/options/options.test.ts +++ b/test/options/options.test.ts @@ -3,8 +3,10 @@ import { validateOptions } from '../../src/options/options'; const validOptions = { accessToken: 'myAccessToken', all: false, + apiHostname: 'api.github.com', branchChoices: [], branches: ['branchA'], + gitHostname: 'github.com', labels: [], multiple: false, multipleBranches: true, diff --git a/test/services/git.test.ts b/test/services/git.test.ts index 80f33f76..c230c79e 100644 --- a/test/services/git.test.ts +++ b/test/services/git.test.ts @@ -8,7 +8,8 @@ describe('addRemote', () => { accessToken: 'myAccessToken', owner: 'elastic', repoName: 'kibana', - username: 'elastic' + username: 'elastic', + gitHostname: 'github.com' }); return expect(spy).toHaveBeenCalledWith( @@ -23,7 +24,8 @@ describe('addRemote', () => { accessToken: 'myAccessToken', owner: 'elastic', repoName: 'kibana', - username: 'sqren' + username: 'sqren', + gitHostname: 'github.com' }); return expect(spy).toHaveBeenCalledWith( @@ -31,4 +33,20 @@ describe('addRemote', () => { { cwd: '/myHomeDir/.backport/repositories/elastic/kibana' } ); }); + + it('allows custom github url', async () => { + const spy = jest.spyOn(rpc, 'exec').mockResolvedValue({} as any); + await addRemote({ + accessToken: 'myAccessToken', + owner: 'elastic', + repoName: 'kibana', + username: 'sqren', + gitHostname: 'github.my-company.com' + }); + + return expect(spy).toHaveBeenCalledWith( + 'git remote add sqren https://myAccessToken@github.my-company.com/sqren/kibana.git', + { cwd: '/myHomeDir/.backport/repositories/elastic/kibana' } + ); + }); }); diff --git a/test/services/github.test.ts b/test/services/github.test.ts index c3449319..1d7e8cff 100644 --- a/test/services/github.test.ts +++ b/test/services/github.test.ts @@ -13,6 +13,7 @@ describe('getCommits', () => { const accessToken = 'myAccessToken'; const author = 'sqren'; const commitSha = 'myCommitSha'; + const apiHostname = 'api.github.com'; setAccessToken(accessToken); mock @@ -40,7 +41,9 @@ describe('getCommits', () => { ] }); - expect(await fetchCommitsByAuthor(owner, repoName, author)).toEqual([ + expect( + await fetchCommitsByAuthor(owner, repoName, author, apiHostname) + ).toEqual([ { message: 'myMessage', pullNumber: 'myPullRequestNumber', @@ -56,6 +59,7 @@ describe('getCommits', () => { const accessToken = 'myAccessToken'; const author = 'sqren'; const commitSha = 'myCommitSha'; + const apiHostname = 'api.github.com'; setAccessToken(accessToken); mock @@ -77,7 +81,9 @@ describe('getCommits', () => { ) .reply(200, { items: [] }); - expect(await fetchCommitsByAuthor(owner, repoName, author)).toEqual([ + expect( + await fetchCommitsByAuthor(owner, repoName, author, apiHostname) + ).toEqual([ { message: 'myMessage', pullNumber: undefined, @@ -85,4 +91,50 @@ describe('getCommits', () => { } ]); }); + + it('allows a custom github api hostname', async () => { + const mock = new MockAdapter(axios); + const owner = 'elastic'; + const repoName = 'kibana'; + const accessToken = 'myAccessToken'; + const author = 'sqren'; + const commitSha = 'myCommitSha'; + const apiHostname = 'api.github.my-company.com'; + setAccessToken(accessToken); + + mock + .onGet( + `https://${apiHostname}/repos/${owner}/${repoName}/commits?access_token=${accessToken}&per_page=5&author=${author}` + ) + .reply(200, [ + { + commit: { + message: 'myMessage' + }, + sha: commitSha + } + ]); + + mock + .onGet( + `https://${apiHostname}/search/issues?q=repo:${owner}/${repoName}+${commitSha}+base:master&access_token=${accessToken}` + ) + .reply(200, { + items: [ + { + number: 'myPullRequestNumber' + } + ] + }); + + expect( + await fetchCommitsByAuthor(owner, repoName, author, apiHostname) + ).toEqual([ + { + message: 'myMessage', + pullNumber: 'myPullRequestNumber', + sha: 'myCommitSha' + } + ]); + }); }); diff --git a/test/steps/doBackportVersions.test.ts b/test/steps/doBackportVersions.test.ts index 8a59a4e3..05548595 100644 --- a/test/steps/doBackportVersions.test.ts +++ b/test/steps/doBackportVersions.test.ts @@ -58,7 +58,8 @@ describe('doBackportVersion', () => { 'sqren', ['backport'], '[{baseBranch}] {commitMessages}', - 'myPrSuffix' + 'myPrSuffix', + 'api.github.com' ); }); @@ -109,7 +110,8 @@ describe('doBackportVersion', () => { 'sqren', ['backport'], '[{baseBranch}] {commitMessages}', - undefined + undefined, + 'api.github.com' ); }); @@ -171,7 +173,8 @@ describe('doBackportVersion', () => { 'sqren', ['backport'], 'myPrTitle', - undefined + undefined, + 'api.github.com' ); return { logSpy, execSpy, promise }; diff --git a/test/steps/getCommits.test.ts b/test/steps/getCommits.test.ts index 25012767..0a4b3393 100644 --- a/test/steps/getCommits.test.ts +++ b/test/steps/getCommits.test.ts @@ -22,7 +22,12 @@ describe('getCommitBySha', () => { items: [] }); - const commits = await getCommitBySha('elastic', 'kibana', 'myCommitSha'); + const commits = await getCommitBySha( + 'elastic', + 'kibana', + 'myCommitSha', + 'api.github.com' + ); expect(commits).toEqual({ message: '[Chrome] Bootstrap Angular into document.body (#15158)', sha: 'myCommitSha', @@ -39,7 +44,7 @@ describe('getCommitBySha', () => { }); await expect( - getCommitBySha('elastic', 'kibana', 'myCommitSha') + getCommitBySha('elastic', 'kibana', 'myCommitSha', 'api.github.com') ).rejects.toThrowError('No commit found for SHA: myCommitSha'); }); @@ -58,7 +63,9 @@ describe('getCommitBySha', () => { items: [{ number: 1338 }] }); - expect(await getCommitBySha('elastic', 'kibana', 'myCommitSha')).toEqual({ + expect( + await getCommitBySha('elastic', 'kibana', 'myCommitSha', 'api.github.com') + ).toEqual({ message: '[Chrome] Bootstrap Angular into document.body (#15158)', pullNumber: 1338, sha: 'myCommitSha' diff --git a/test/steps/maybeSetupRepo.test.ts b/test/steps/maybeSetupRepo.test.ts index 6de478a3..4f8ec7f1 100644 --- a/test/steps/maybeSetupRepo.test.ts +++ b/test/steps/maybeSetupRepo.test.ts @@ -14,7 +14,8 @@ describe('maybeSetupRepo', () => { owner: 'elastic', repoName: 'kibana', username: 'sqren', - accessToken: 'myAccessToken' + accessToken: 'myAccessToken', + gitHostname: 'github.com' }); } catch (e) { expect(rimraf).toHaveBeenCalledWith( diff --git a/test/steps/steps.test.ts b/test/steps/steps.test.ts index 8d728dc3..9e7608bb 100644 --- a/test/steps/steps.test.ts +++ b/test/steps/steps.test.ts @@ -165,6 +165,7 @@ describe('run through steps', () => { await initSteps({ accessToken: 'myAccessToken', all: false, + apiHostname: 'api.github.com', branches: [], branchChoices: [ { name: '6.x' }, @@ -173,6 +174,7 @@ describe('run through steps', () => { { name: '5.5' }, { name: '5.4' } ], + gitHostname: 'github.com', labels: [], multiple: false, multipleBranches: false, @@ -193,17 +195,23 @@ describe('run through steps', () => { expect(github.fetchCommitsByAuthor).toHaveBeenCalledWith( 'elastic', 'kibana', - 'sqren' + 'sqren', + 'api.github.com' ); }); it('createPullRequest should be called with correct args', () => { - expect(github.createPullRequest).toHaveBeenCalledWith('elastic', 'kibana', { - base: '6.2', - body: `Backports the following commits to 6.2:\n - myCommitMessage (#myPullRequestNumber)\n\nmyPrDescription`, - head: 'sqren:backport/6.2/pr-myPullRequestNumber', - title: 'myPrTitle' - }); + expect(github.createPullRequest).toHaveBeenCalledWith( + 'elastic', + 'kibana', + { + base: '6.2', + body: `Backports the following commits to 6.2:\n - myCommitMessage (#myPullRequestNumber)\n\nmyPrDescription`, + head: 'sqren:backport/6.2/pr-myPullRequestNumber', + title: 'myPrTitle' + }, + 'api.github.com' + ); }); it('prompt calls should match snapshot', () => {