argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.92k stars 5.46k forks source link

Inconsistent logic when finding a HEAD branch #16433

Open zetsub0u opened 11 months ago

zetsub0u commented 11 months ago

Checklist:

Describe the bug A common idea is to poing revision and targetRevision in Application and ApplicationSet to HEAD, which usually is a ref to the tip of your main branch (usually master). the resolution of names to refspecs happens at the client, so HEAD is a special case that gets translated to this other refspec.

The problem arises when someone pushes an actual branch named HEAD, clients still respect following the redirection, argo actually pulls the branch instead, which causes quite the confusion as you see unexpected commits being pulled.

To Reproduce Have applications pointing to HEAD.

  1. Create a branch with older commits or recognizable commits
  2. git push origin refs/heads/HEAD (creates a remote branch called HEAD)
  3. Observe ArgoCD behavior, commits being pulled HEAD references in applications will be from this branch.

Expected behavior Ideally i would expect it to follow the normal git cli/github behavior when doing standard calls which is to follow the HEAD redirect.

I believe it might be caused by this rename when finding the string HEAD, but i'm not sure: https://github.com/argoproj/argo-cd/blob/78460c4b365bcb1f58514abac1b37482f7eb561d/util/git/client.go#L442-L446

Screenshots Github Web UI correctly sends you to the last commit on master when opening this url: image ArgoCD Web UI shows the commit it found at HEAD, which is different, and is the tip of the branch called HEAD in this case. image

Version v2.6.8

andrii-korotkov-verkada commented 2 days ago

ArgoCD versions 2.10 and below have reached EOL. Can you upgrade and let us know if the issue is still present, please?