akkoma-fe/src/services/version/version.service.js
2022-06-14 22:13:51 +03:00

17 lines
355 B
JavaScript

export const extractCommit = versionString => {
// X.Y.Z-1337-gdeadbeef => deadbeef
const commit = versionString.match(/-g(\w+)/i)
if (commit) {
return commit[1]
}
// X.Y.Z-develop => develop
const branch = versionString.match(/-([\w-/]+)$/i)
if (branch) {
return branch[1]
}
// X.Y.Z => vX.Y.Z
return 'v' + versionString
}