-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/git: introduce concrete and partial commit
Introduce concrete and partial commits. Concrete commits have all the information from remote including the hash and commit content. Partial commits are based on locally available copy of a repo, they may only contain the commit hash and reference. IsConcreteCommit() can be used to find out if a given commit is based on local information or full remote repo information. Update go-git and libgit2 branch/tag clone optimization to return a partial commit and no error. Update and simplify the go-git and libgit2 tests for the same. Signed-off-by: Sunny <[email protected]>
- Loading branch information
Showing
7 changed files
with
391 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package git | |
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
@@ -263,3 +264,41 @@ of the commit`, | |
}) | ||
} | ||
} | ||
|
||
func TestIsConcreteCommit(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
commit Commit | ||
result bool | ||
}{ | ||
{ | ||
name: "concrete commit", | ||
commit: Commit{ | ||
Hash: Hash("foo"), | ||
Reference: "refs/tags/main", | ||
Author: Signature{ | ||
Name: "user", Email: "[email protected]", When: time.Now(), | ||
}, | ||
Committer: Signature{ | ||
Name: "user", Email: "[email protected]", When: time.Now(), | ||
}, | ||
Signature: "signature", | ||
Encoded: []byte("commit-content"), | ||
Message: "commit-message", | ||
}, | ||
result: true, | ||
}, | ||
{ | ||
name: "partial commit", | ||
commit: Commit{Hash: Hash("foo")}, | ||
result: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
g := NewWithT(t) | ||
g.Expect(IsConcreteCommit(tt.commit)).To(Equal(tt.result)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.