Shulhan
unread,Apr 30, 2020, 12:13:12 PM4/30/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Sometimes when I push too fast on one of dependencies, the Go proxy can't
catch up the latest non-tagged commit on remote server. So, I need to get the
latest module version on tip of git commit using the following shell script,
----
#!/bin/sh
MODNAME=$(go list -m)
DATE=$(date -u -r `git log -n 1 --date=local --pretty=format:'%ct'` +%Y%0m%0d%0H%0M%0S)
HASH=$(git log -n 1 --pretty=format:'%h' --abbrev=12)
TAG=$(git describe --abbrev=0 --tags 2>/dev/null)
if [[ "${TAG}" == "" ]]; then
TAG="v0.0.0"
else
IFS=. read MAJOR MINOR PATCH <<<"${TAG}"
PATCH=$((PATCH+1))
TAG=${MAJOR}.${MINOR}.${PATCH}
fi
echo ${MODNAME} ${TAG}-${DATE}-${HASH}
----
and update the version on go.mod manually to force the proxy to get the
defined version. I know that I should test and maybe use "replace" directive
before committing any changes to one of dependencies, but one or two things
sometimes slip out of our eyes.
I have read the documentation on "go help list" and search the web for any
alternatives, unfortunately I can't find one. If anyone have any idea about
go command that can replace above script, that would be great.
Regards,
Shulhan