Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"-git_revision" option of "make" subcommand results in unexpected package version when the upstream repo has two tags at the same commit #226

Open
wlyu2 opened this issue Nov 27, 2024 · 0 comments

Comments

@wlyu2
Copy link

wlyu2 commented Nov 27, 2024

When I try to create a Debian package for "k8s.io/cli-runtime", I get the following output:

# dh-make-golang make -git_revision v0.31.3 -type l k8s.io/cli-runtime                                                                                                    
2024/11/26 14:33:52 Starting "dh-make-golang v0.7.0 linux/amd64"          
2024/11/26 14:33:52 Downloading "k8s.io/cli-runtime/..."                                                                                                                                                    
2024/11/26 14:33:54 Determining upstream version number             
2024/11/26 14:33:54 Found latest tag "kubernetes-1.31.3"                   
2024/11/26 14:33:54 WARNING: Latest tag "kubernetes-1.31.3" is not a valid SemVer version
2024/11/26 14:33:54 Latest tag "kubernetes-1.31.3" matches master  
2024/11/26 14:33:54 Package version is "1.31.3"

When I check the upstream repo "k8s.io/cli-runtime", I observe that both tags `kubernetes-1.31.3" and "v0.31.3" refers to the same commit:

$ git branch
* (HEAD detached at v0.31.3)
  master
  
$ git log -1
commit 597e981c50a2b9cc2f484e6fc94f618822b62888 (HEAD, tag: v0.31.3, tag: kubernetes-1.31.3)
Author: Kubernetes Publisher <[email protected]>
Date:   Thu Nov 21 05:10:54 2024 +0000

    Update dependencies to v0.31.3 tag
`
$ git remote -v
origin  https://github.com/kubernetes/cli-runtime.git (fetch)
origin  https://github.com/kubernetes/cli-runtime.git (push)

I assume the behavior of "dh-make-golang" is because

  • tag kubernetes-1.31.3 is created at a later time after v0.31.3 thus making it the latest tag before the HEAD.
  • "dh-make-golang" uses "git describe" which fetches the latest tag before the HEAD [1] which is checked out to the value specified by option "-git_revision" by "dh-make-golang" [2].

I would hope that, if the git revision specified by "-git_revision" is a valid tag, "dh-make-golang" should be using that tag without any additional heuristics because:

  • This, I think, would be more intuitive.
  • Otherwise, I would have to manually fix the package version in the templates generated by "dh-make-golang" in this particular case of packaging "v0.31.3" of "k8s.io/cli-runtime".

Reference

[1]

cmd := exec.Command("git", "describe", "--abbrev=0", "--tags", "--exclude", "*/v*")

[2]
if err := u.get(gopath, repo, revision); err != nil {

return rr.VCS.CreateAtRev(dir, rr.Repo, rev)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant