Skip to content

Instantly share code, notes, and snippets.

@dolmen
Created January 28, 2021 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dolmen/452014dd251d173f65c6d437885206c6 to your computer and use it in GitHub Desktop.
Save dolmen/452014dd251d173f65c6d437885206c6 to your computer and use it in GitHub Desktop.
Get Go module+version string from a commit from GitHub

github-go-version

Usage

github-go-version <owner>/<repo> <commit>
#!/usr/bin/env bash
# user/repo
user_repo="$1"
commit="$2"
date="$(curl -s -X GET -H "Cache-Control: no-cache" -L https://api.github.com/repos/"$user_repo"/commits/"$commit" | jq -r '.commit.committer.date | gsub("[^0-9]"; "")' )"
echo "github.com/$user_repo@v0.0.0-$date-${commit%????????????????????????????}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment