From 66842efd8117726600da62459aa35cd11e3972a0 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Wed, 3 Jul 2019 12:02:56 -0400
Subject: [PATCH 1/2] update regex for commit hash
---
src/services/version/version.service.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/services/version/version.service.js b/src/services/version/version.service.js
index a750b0dd17..2e11bf3a14 100644
--- a/src/services/version/version.service.js
+++ b/src/services/version/version.service.js
@@ -1,6 +1,6 @@
export const extractCommit = versionString => {
- const regex = /-g(\w+)$/i
+ const regex = /-g(\w+)/i
const matches = versionString.match(regex)
return matches ? matches[1] : ''
}
From c7127541500979233a350e4b8c2d98ae64eb1049 Mon Sep 17 00:00:00 2001
From: taehoon
Date: Fri, 5 Jul 2019 13:38:52 -0400
Subject: [PATCH 2/2] add unit tests
---
.../specs/services/version/version.service.spec.js | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 test/unit/specs/services/version/version.service.spec.js
diff --git a/test/unit/specs/services/version/version.service.spec.js b/test/unit/specs/services/version/version.service.spec.js
new file mode 100644
index 0000000000..519145ee1d
--- /dev/null
+++ b/test/unit/specs/services/version/version.service.spec.js
@@ -0,0 +1,11 @@
+import { extractCommit } from 'src/services/version/version.service.js'
+
+describe('extractCommit', () => {
+ it('return short commit hash following "-g" characters', () => {
+ expect(extractCommit('1.0.0-45-g5e7aeebc')).to.eql('5e7aeebc')
+ })
+
+ it('return short commit hash without branch name', () => {
+ expect(extractCommit('1.0.0-45-g5e7aeebc-branch')).to.eql('5e7aeebc')
+ })
+})