utils.ts 383 B

12345678910111213
  1. const child_process = require('child_process');
  2. export const getBranchInfo = () => {
  3. const latestCommit = child_process
  4. .execSync('git rev-parse HEAD')
  5. .toString()
  6. .trim();
  7. const versionTag = child_process
  8. .execSync(`git tag --contains ${latestCommit}`)
  9. .toString()
  10. .trim();
  11. return { version: versionTag || '', commitId: latestCommit.slice(0, 7) };
  12. };