From 14b7dfa00792cc571fd58d3a7adc6cb50abb42db Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Thu, 13 Apr 2017 21:55:33 +0300 Subject: [PATCH] fix(aio): create a proper commit link on preview comments (#15941) Previously, only a few characters of the SHA would appear on the preview link comment posted on the PR. This was usually enough for GitHub to create a link to the corresponding commit, but it was possible to have collisions with other commits with the same first characters (which prevented GitHub from identifying the correct commit and create a link.) This commit fixes this issue by including the full SHA on the commentso GitHub can identify the correct commit and create the link. GitHub will automatically truncate the link text (by default to 7 chars unless more are necessary to uniquely identify the commit). --- .../scripts-js/lib/upload-server/upload-server-factory.ts | 2 +- .../scripts-js/test/upload-server/upload-server-factory.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/upload-server-factory.ts b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/upload-server-factory.ts index 7f174be45a..cace76d61f 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/upload-server-factory.ts +++ b/aio/aio-builds-setup/dockerbuild/scripts-js/lib/upload-server/upload-server-factory.ts @@ -58,7 +58,7 @@ class UploadServerFactory { const githubPullRequests = new GithubPullRequests(githubToken, repoSlug); buildCreator.on(CreatedBuildEvent.type, ({pr, sha}: CreatedBuildEvent) => { - const body = `The angular.io preview for ${sha.slice(0, 7)} is available [here][1].\n\n` + + const body = `The angular.io preview for ${sha} is available [here][1].\n\n` + `[1]: https://pr${pr}-${sha}.${domainName}/`; githubPullRequests.addComment(pr, body); diff --git a/aio/aio-builds-setup/dockerbuild/scripts-js/test/upload-server/upload-server-factory.spec.ts b/aio/aio-builds-setup/dockerbuild/scripts-js/test/upload-server/upload-server-factory.spec.ts index 3784b747a2..276c328210 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-js/test/upload-server/upload-server-factory.spec.ts +++ b/aio/aio-builds-setup/dockerbuild/scripts-js/test/upload-server/upload-server-factory.spec.ts @@ -143,7 +143,7 @@ describe('uploadServerFactory', () => { it('should post a comment on GitHub on \'build.created\'', () => { const prsAddCommentSpy = spyOn(GithubPullRequests.prototype, 'addComment'); - const commentBody = 'The angular.io preview for 1234567 is available [here][1].\n\n' + + const commentBody = 'The angular.io preview for 1234567890 is available [here][1].\n\n' + '[1]: https://pr42-1234567890.domain.name/'; buildCreator.emit(CreatedBuildEvent.type, {pr: 42, sha: '1234567890'});