As part of a Capistrano Ruby task that deploys to a server, I'd like it to output the Git message and commit of the code it just deployed.
With this:
git_message = `git log -1 HEAD --pretty=format:%s`
git_commit = `git rev-parse HEAD`
git_commit = "https://example.com/myorg/myrepo/commit/" + git_commit
execute "echo \"Deployed \\\"#{git_message}\\\": #{git_commit}\" | a_command_that_posts_to_slack"
It's outputting something like this:
Deployed "Merge branch 'feature/some-feature' into develop": https://example.com/myorg/myrepo/commit/0fdfa09fbfe012649fb0a998aa2e99cb5fd7c8b3;
Note that semicolon at the very end of the commit hash. I've confirmed using puts
that git_commit
doesn't end with a semicolon, and git_message
doesn't have one, and doesn't have one after it either.
What's adding the semicolon and how can I remove it?