From 87d82147a3dba2e5a2baa6c061f7b26d77c217da Mon Sep 17 00:00:00 2001 From: leon Date: Wed, 9 Sep 2026 11:31:20 +0200 Subject: [PATCH] feat: commit id --- app.config.js | 24 ++++++++++++++++++++++++ src/screens/Profile/Settings.js | 9 +++++---- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 app.config.js diff --git a/app.config.js b/app.config.js new file mode 100644 index 0000000..d62f9ed --- /dev/null +++ b/app.config.js @@ -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(), + }, +}) diff --git a/src/screens/Profile/Settings.js b/src/screens/Profile/Settings.js index 9d646ed..ea99a7f 100644 --- a/src/screens/Profile/Settings.js +++ b/src/screens/Profile/Settings.js @@ -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 = () => {