2025-02-28 14:03:43 -05:00
|
|
|
import childProcess from 'child_process'
|
|
|
|
|
|
2026-01-06 16:22:52 +02:00
|
|
|
export const getCommitHash = () => {
|
|
|
|
|
const subst = '$Format:%h$'
|
|
|
|
|
if (!subst.match(/Format:/)) {
|
2025-02-28 14:03:43 -05:00
|
|
|
return subst
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
return childProcess
|
|
|
|
|
.execSync('git rev-parse --short HEAD')
|
|
|
|
|
.toString()
|
|
|
|
|
.trim()
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Failed run git:', e)
|
|
|
|
|
return 'UNKNOWN'
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-06 16:22:52 +02:00
|
|
|
}
|