我想编写一个 shell 程序来检查我项目中的所有 go 模块依赖项是否都在其存储库中的最新主版本上。特别是,我想知道每个模块在哪个分支上。有一个文件“go.mod”,其中包含列为 {module}-{commit time}-{commit ID}
的每个依赖项。 .如何从 SHA-1(commit id) 或 shell 程序的其他消息中获取他们的 git-branch 名称。
我试过go list -m -u all
, 如果依赖项不是最新的,则仅显示最新版本。等 git.xxx.com/project v0.0.0-20191119034146-e894bf51bdcd [v0.0.0-20200609070643-fd412b12b811]。在不克隆 repos 的情况下,go 模块工具可以解决这个问题吗?
最佳答案
我无法弄清楚如何仅使用 go 工具找到当前依赖项属于哪个分支。但是有一种方法可以使用 git 找到提交所在的分支。git clone <repo-url> && cd <repo> && git branch -a --contains <commit>
引用:Finding what branch a Git commit came from
关于go - 如何通过命令行找出 go.mod 中的依赖项属于哪个 git-branch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62755337/