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

Azure DevOps: fails to checkout and determine revision for GitRepository.spec.ref.name #1166

Closed
nashton opened this issue Jul 12, 2023 · 3 comments · Fixed by #1175
Closed
Assignees
Labels
wontfix This will not be worked on

Comments

@nashton
Copy link

nashton commented Jul 12, 2023

Flux v.0.42
This error relates to the use case described in issue 963. Our git repository is hosted on Azure Devops.

When using the GitRepository.spec.ref.name: refs/pull/430/merge we get an error as below:

GitRepository reconciliation failed: 'failed to checkout and determine revision: unable to resolve commit object for 'cae9c52ebae189cf07cec3635137a2e4f1ad56da': object not found'

This error only happens, when the commit that the git reference points to, does not exist in any branch under refs/heads or /refs/tags.
It works when I push the cae9c52ebae189cf07cec3635137a2e4f1ad56da commit into a "normal" branch under /refs/heads/.

The implementation of spec.ref.name, does not take into account, that the default git refspec is +refs/heads/*:refs/remotes/origin/*, hence git clone will not download the git references outside refs/heads or refs/tags, so git checkout will fail.

A simple solution would be to add a git fetch origin <git-reference> before trying to do a git checkout in the code. Unfortunately, it seems that go-git does not fully implement the v2 wire protocol, so git fetch might corrupt the repository.

@aryan9600
Copy link
Member

This occurs because Azure Devops doesn't let you track the head of a PR. It lets you fetch the merge commit that will be created when you merge the PR, hence the use of merge and not head, that's followed by GitHub, GitLab.
Flux fails will with an unable to resolve commit object error because that commit object doesn't exist at that point since its the merge commit that will be created in the future. Another drawback of supporting fetching the merge commit instead of the HEAD, is that you can't fetch the PR's changes if the PR has merge conflicts. You can test this by creating a PR that has merge conflicts and notice it not being listed when you do a git ls-remote.

I fear you might be correct about a git fetch corrupting the repository because of the lack of support of git v2 in go-git. cc: @pjbgf

@pjbgf
Copy link
Member

pjbgf commented Jul 19, 2023

go-git will error on any follow-up fetch operations, but the repository state itself won't be corrupted. But from a Flux perspective that would mean it needed to be discarded and re-cloned.

@stefanprodan stefanprodan changed the title Gitrepository fails to checkout and determine revision for GitRepository.spec.ref.name Azure DevOps: fails to checkout and determine revision for GitRepository.spec.ref.name Jul 19, 2023
@stefanprodan stefanprodan added the wontfix This will not be worked on label Jul 19, 2023
@stefanprodan
Copy link
Member

Best we can do is to document that .spec.ref.name is not compatible with Azure DevOps. cc @aryan9600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants