We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
The following snippet allows you to extract the SHA1 of the git commit from within elixir. It is useful to attach the SHA1 to your release or code so that if therea are any issues you can quickly checkout the commit and look into it.
You can also get the branch name if required.
def git_commit_sha() do
System.cmd("git", ["rev-parse", "--short", "HEAD"])
|> elem(0)
|> String.trim()
end
def git_branch_name() do
System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"])
|> elem(0)
|> String.trim()
end
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.