From 0ea689c27aecf322664e0a0a852c382c64b3bd8d Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Mon, 28 Nov 2016 10:56:54 +0100 Subject: [PATCH] Shorten git reference if commit --- lib/github.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/github.js b/lib/github.js index 9fcfacb..3492a56 100644 --- a/lib/github.js +++ b/lib/github.js @@ -44,10 +44,15 @@ const splittedURL = fullURL => { // ...and then remove it from the parts pathParts.splice(0, 2) - return { - main, - ref: pathParts.length >= 2 ? pathParts[1] : '' + // Assign Git reference + let ref = pathParts.length >= 2 ? pathParts[1] : '' + + // Shorten SHA for commits + if (pathParts[0] && pathParts[0] === 'commit') { + ref = ref.substring(0, 7) } + + return {main, ref} } export const gitPathParts = main => {