feat: commit id

This commit is contained in:
leon
2026-09-09 11:31:20 +02:00
parent 0a6603d917
commit 87d82147a3
2 changed files with 29 additions and 4 deletions
+24
View File
@@ -0,0 +1,24 @@
const { execFileSync } = require('node:child_process')
const getCommitId = () => {
const easCommitId = process.env.EAS_BUILD_GIT_COMMIT_HASH?.trim()
if (easCommitId) {
return easCommitId.slice(0, 8)
}
try {
return execFileSync('git', ['rev-parse', '--short=8', 'HEAD'], {
encoding: 'utf8',
}).trim()
} catch {
return null
}
}
module.exports = ({ config }) => ({
...config,
extra: {
...config.extra,
commitId: getCommitId(),
},
})
+5 -4
View File
@@ -49,13 +49,14 @@ const SETTINGS = [
const getVersionLabel = () => {
const appVersion = Constants.expoConfig?.version || 'inconnue'
const updateId = typeof Updates.updateId === 'string' ? Updates.updateId.slice(0, 8) : null
const commitId = Constants.expoConfig?.extra?.commitId
const source = __DEV__ ? 'développement' : Updates.isEmbeddedLaunch ? 'intégrée' : 'OTA'
if (updateId) {
return `Version ${appVersion} · mise à jour ${updateId}`
if (typeof commitId === 'string' && commitId) {
return `Version ${appVersion} · ${source} · commit ${commitId}`
}
return `Version ${appVersion} · ${__DEV__ ? 'développement' : 'intégrée'}`
return `Version ${appVersion} · ${source}`
}
const Settings = () => {