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/libgit2: set CheckoutForce on branch strategy #589

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Feb 22, 2022

In the recent update from libgit2 1.1.x to 1.3.x, something seems to
have changed upstream. Resulting in the clone of a branch ending up
with a semi-bare file system state (in other words: without any files
present in the directory).

This commit patches the clone behavior to set the CheckoutForce
strategy as CheckoutOption, which mitigates the issue.

In addition, test cases have been added to ensure we do not run into
this again by asserting the state of the branch after cloning.

Fixes: #588

@hiddeco hiddeco added area/git Git related issues and pull requests bug Something isn't working labels Feb 22, 2022
In the recent update from libgit2 1.1.x to 1.3.x, something seems to
have changed upstream. Resulting in the clone of a branch ending up
with a semi-bare file system state (in other words: without any files
present in the directory).

This commit patches the clone behavior to set the `CheckoutForce`
strategy as `CheckoutOption`, which mitigates the issue.

In addition, test cases have been added to ensure we do not run into
this again by asserting the state of the branch after cloning.

Signed-off-by: Hidde Beydals <hello@hidde.co>
If there is no configuration set for `init.defaultBranch`, it does not
return an error but an empty string. We now take this into account so
we do not overwrite the default, and make the default `master` to match
with libgit2 defaults.

In addition, some comments have been added to not get confused about
what commits we are checking against.

Signed-off-by: Hidde Beydals <hello@hidde.co>
@hiddeco hiddeco force-pushed the libgit2-branch-checkout branch from f7192ab to eff40e2 Compare February 22, 2022 15:32
@hiddeco hiddeco changed the title git/libgit2: manually checkout tree for branch git/libgit2: set CheckoutForce on branch strategy Feb 22, 2022
@hiddeco hiddeco marked this pull request as ready for review February 22, 2022 15:43
@stefanprodan
Copy link
Member

Can we add a test for a YAML file that we place in Git, then check that the file in the artifact contains the exact same YAML content as the one in Git?

@hiddeco
Copy link
Member Author

hiddeco commented Feb 22, 2022

@stefanprodan it would be better to add this in rewrite-dev as none of the tests in main will remain.

@hiddeco hiddeco merged commit bd3d781 into main Feb 22, 2022
@hiddeco hiddeco deleted the libgit2-branch-checkout branch February 22, 2022 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Empty artifacts after the libgit2 upgrade to 1.3.0
3 participants