From a13e0fb1b3c1a8ab82754079cdf136652bbf7aef Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 6 May 2021 23:28:15 -0700 Subject: [PATCH] Clean repository after each checkout Previously, when checking out a tag, folders that had only existed in the previous tag (e.g., `extras/test` when going from ArduinoIoTCloud@0.11.0 to ArduinoIotCloud@0.10.0) were left behind as empty, and would pollute the library archives. So it's necessary to do a clean on the repository after each checkout to remove any untracked objects. --- libraries/git_integration_test.go | 2 ++ sync_libraries.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/libraries/git_integration_test.go b/libraries/git_integration_test.go index 717d5492..23895492 100644 --- a/libraries/git_integration_test.go +++ b/libraries/git_integration_test.go @@ -47,6 +47,8 @@ func TestUpdateLibraryJson(t *testing.T) { require.NoError(t, err) err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag, Force: true}) require.NoError(t, err) + err = repoTree.Clean(&git.CleanOptions{Dir: true}) + require.NoError(t, err) library, err := GenerateLibraryFromRepo(r) require.NoError(t, err) diff --git a/sync_libraries.go b/sync_libraries.go index b502fca1..1964ab5b 100644 --- a/sync_libraries.go +++ b/sync_libraries.go @@ -244,6 +244,10 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta return fmt.Errorf("Error checking out repo: %s", err) } + if err = repoTree.Clean(&git.CleanOptions{Dir: true}); err != nil { + return fmt.Errorf("Error cleaning repo: %s", err) + } + // Create library metadata from library.properties library, err := libraries.GenerateLibraryFromRepo(repo) if err != nil {