-2

I want to write a shell program to check whether all go module dependencies in my project are on newest master version in their repositories. In particular, I want to know which branch each module is on. There is a file "go.mod" containing each dependency listed as {module}-{commit time}-{commit ID}. How can I get their git-branch name from SHA-1(commit id) or other message by shell program.

I have tried go list -m -u all, only showing the newest edition if the dependency is not up-to-date. etc. git.xxx.com/project v0.0.0-20191119034146-e894bf51bdcd [v0.0.0-20200609070643-fd412b12b811]. Without cloning the repos, can go module tools resolve this quetion?

classSalt
  • 11
  • 1
  • 2
    What makes you think that SHA is associated with any branch name at all? Or that it's only one? – Jonathan Hall Jul 06 '20 at 13:38
  • It's the commit ID of a branch of Git. Now the quetion is how to find this branch, without cloning the repo, by go tools or other command line method. – classSalt Jul 07 '20 at 03:38

1 Answers1

1

I couldn't figure out how to find which branch the current dependency belongs to using only go tools. But there is a way to find which branch the commit is on using git.

git clone <repo-url> && cd <repo> && git branch -a --contains <commit>

Reference: Finding what branch a Git commit came from

hyz
  • 472
  • 3
  • 10