From a8fbc45ed35537822ea878b7fe579716a188e372 Mon Sep 17 00:00:00 2001 From: Jan Kuri Date: Sun, 20 Aug 2017 05:20:51 +0200 Subject: [PATCH] fix(pm): correct sha for last commit --- src/api/process-manager.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/process-manager.ts b/src/api/process-manager.ts index 7598e5604..42b0ed452 100644 --- a/src/api/process-manager.ts +++ b/src/api/process-manager.ts @@ -326,7 +326,7 @@ function prepareJob(buildId: number, jobId: number, cmds: any, sshAndVnc = false .then(() => getBuild(buildId)) .then(build => { if (build.repository.access_token) { - const sha = build.data.after; + const sha = build.data.after || build.data.pull_request.head.sha; const name = build.data.repository.full_name; const gitUrl = `https://api.github.com/repos/${name}/statuses/${sha}`; const abstruseUrl = `${config.url}/build/${buildId}`; @@ -358,7 +358,7 @@ function prepareJob(buildId: number, jobId: number, cmds: any, sshAndVnc = false .then(() => getBuild(buildId)) .then(build => { if (build.repository.access_token) { - const sha = build.data.after; + const sha = build.data.after || build.data.pull_request.head.sha; const name = build.data.repository.full_name; const gitUrl = `https://api.github.com/repos/${name}/statuses/${sha}`; const abstruseUrl = `${config.url}/build/${buildId}`; @@ -453,7 +453,7 @@ export function stopBuild(buildId: number): Promise { const abstruseUrl = `${config.url}/build/${buildId}`; return setGitHubStatusFailure(gitUrl, abstruseUrl, buildData.repository.access_token); } - }); + }).catch(err => console.error(err)); } export function restartJob(jobId: number): Promise { @@ -481,7 +481,7 @@ export function restartJob(jobId: number): Promise { .then(() => getBuild(jobData.builds_id)) .then(build => { if (build.repository.access_token) { - const sha = build.data.after; + const sha = build.data.after || build.data.pull_request.head.sha; const name = build.data.repository.full_name; const gitUrl = `https://api.github.com/repos/${name}/statuses/${sha}`; const abstruseUrl = `${config.url}/build/${jobData.build_id}`; @@ -490,7 +490,7 @@ export function restartJob(jobId: number): Promise { } else { return Promise.resolve(); } - }); + }).catch(err => console.error(err)); } export function restartJobWithSshAndVnc(jobId: number): Promise { @@ -518,7 +518,7 @@ export function restartJobWithSshAndVnc(jobId: number): Promise { .then(() => getBuild(jobData.builds_id)) .then(build => { if (build.repository.access_token) { - const sha = build.data.after; + const sha = build.data.after || build.data.pull_request.head.sha; const name = build.data.repository.full_name; const gitUrl = `https://api.github.com/repos/${name}/statuses/${sha}`; const abstruseUrl = `${config.url}/build/${jobData.build_id}`;