Search code examples
ruby-on-railsgitgithubcapistrano

Get Github URL for tag SHA


With a Rails Capistrano deploy, if you deploy from git you get a REVISION file in your deployment. It's a SHA of the object deployed.

I have a bit of admin-only code that links to: https://github.com/<company>/<project>/commit/<sha>

That way devs can easily double check the details of the current deployment. It worked and was useful.

I recently changed our deployment system from branch-based deployment to (annotated)-tag-based deployment.

Now the REVISION contains a SHA for the tag.

I cannot figure out how to generate a URL to GitHub with this SHA.

https://github.com/<company>/<project>/tree/<tag> works, but https://github.com/<company>/<project>/tree/<tag-sha> doesn't.

Attempts to resolve this with the API failed as well.

So given a tag-SHA, how do I generate the GitHub URL for it?


Solution

  • Capistrano deployment from git generates a short SHA.
    see https://github.com/capistrano/capistrano/blob/bfc4a82359251b8fd28165fc0d981c7f8f0baf99/lib/capistrano/git.rb#L43

    Github's API requires a full SHA.

    That is the problem.

    I've opened an issue asking not to shorten SHAs (unless there is a valid reason against this request). https://github.com/capistrano/capistrano/issues/1468