fleet
fleet copied to clipboard
Gitrepos based on revision show the wrong commit in Status
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
I'm using the following gitrepo
:
apiVersion: fleet.cattle.io/v1alpha1
kind: GitRepo
metadata:
name: sample
namespace: fleet-local
spec:
repo: "https://github.com/0xavi0/fleet-experiments-master"
revision: v0.0.0
paths:
- helm-test-tags
The git repository has 3 tags
- v0.0.0
- v0.0.1
- v0.0.2
After applying the gitrepo
(which references tag v0.0.0) we can see the following commit
in the gitrepo
$ kubectl get gitrepo -n fleet-local sample
NAME REPO COMMIT BUNDLEDEPLOYMENTS-READY STATUS
sample https://github.com/0xavi0/fleet-experiments-master b91254d06622d8e0ace1f76c0926b95af2efb63a 1/1
But b91254d06622d8e0ace1f76c0926b95af2efb63a
is the hash for the repository's HEAD, not the commit for tag v0.0.0
$ git ls-remote https://github.com/0xavi0/fleet-experiments-master
b91254d06622d8e0ace1f76c0926b95af2efb63a HEAD
b91254d06622d8e0ace1f76c0926b95af2efb63a refs/heads/master
b8a525671bfd03f32991b4ccec56517e74b3d7b0 refs/tags/v0.0.0
8e186ca6abd9930e90a129954b4bd0c630f5a7ab refs/tags/v0.0.0^{}
b2f7eacdeda55833e299efdd6955abb68f581547 refs/tags/v0.0.1
a08281305a4320ba4df9cc877e20a295d0c128a4 refs/tags/v0.0.1^{}
ffad72d77b26152ad74053d736cc1b96c82b7c99 refs/tags/v0.0.2
b91254d06622d8e0ace1f76c0926b95af2efb63a refs/tags/v0.0.2^{}
The issue is happening because the LatestCommit
function in the fetch.go file is using the provided branch to get the last commit or master
if none is provided.
As this example is using a revision no branch is provided and we obtain the Commit from master
(head).
Expected Behavior
I would expect to see the commit for the tag instead to the one for HEAD
Steps To Reproduce
Apply the gitrepo referenced and observe the Commit in the gitrepo