Last active
June 5, 2024 15:33
-
-
Save wosephjeber/212f0ca7fea740c3a8b03fc2283678d3 to your computer and use it in GitHub Desktop.
Get branch and commit names from Node (synchronously)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { execSync } = require('child_process'); | |
function executeGitCommand(command) { | |
return execSync(command) | |
.toString('utf8') | |
.replace(/[\n\r\s]+$/, ''); | |
} | |
const BRANCH = executeGitCommand('git rev-parse --abbrev-ref HEAD'); | |
const COMMIT_SHA = executeGitCommand('git rev-parse HEAD'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow thanks, exactly what i've been looking for