Skip to content

Commit a13e0fb

Browse files
committed
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 [email protected] to [email protected]) 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.
1 parent 111802d commit a13e0fb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

libraries/git_integration_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func TestUpdateLibraryJson(t *testing.T) {
4747
require.NoError(t, err)
4848
err = repoTree.Checkout(&git.CheckoutOptions{Hash: *resolvedTag, Force: true})
4949
require.NoError(t, err)
50+
err = repoTree.Clean(&git.CleanOptions{Dir: true})
51+
require.NoError(t, err)
5052

5153
library, err := GenerateLibraryFromRepo(r)
5254
require.NoError(t, err)

sync_libraries.go

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
244244
return fmt.Errorf("Error checking out repo: %s", err)
245245
}
246246

247+
if err = repoTree.Clean(&git.CleanOptions{Dir: true}); err != nil {
248+
return fmt.Errorf("Error cleaning repo: %s", err)
249+
}
250+
247251
// Create library metadata from library.properties
248252
library, err := libraries.GenerateLibraryFromRepo(repo)
249253
if err != nil {

0 commit comments

Comments
 (0)