From 48f04d526e1d56c9fef95d05cb4b88a42031c216 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 6 May 2021 08:24:32 -0700 Subject: [PATCH] Use force checkout Even though I don't know of a situation where this would be needed, it is how it was done before the switch to using `github.com/go-git/go-git`: https://github.com/bcmi-labs/arduino-modules/blob/v1.1.12/git/git_helper.go#L93 Since the previous system was working well, it seems best to emulate its behavior as closely as possible. --- libraries/git_integration_test.go | 2 +- sync_libraries.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/git_integration_test.go b/libraries/git_integration_test.go index c6134c17..717d5492 100644 --- a/libraries/git_integration_test.go +++ b/libraries/git_integration_test.go @@ -45,7 +45,7 @@ func TestUpdateLibraryJson(t *testing.T) { // Annotated tags have their own hash, different from the commit hash, so the tag must be resolved before checkout resolvedTag, err := r.Repository.ResolveRevision(plumbing.Revision(tag.Hash().String())) require.NoError(t, err) - err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag}) + err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag, Force: true}) require.NoError(t, err) library, err := GenerateLibraryFromRepo(r) diff --git a/sync_libraries.go b/sync_libraries.go index 184fbcfa..b502fca1 100644 --- a/sync_libraries.go +++ b/sync_libraries.go @@ -240,7 +240,7 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta panic(err) } - if err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag}); err != nil { + if err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag, Force: true}); err != nil { return fmt.Errorf("Error checking out repo: %s", err) }