mirror of
https://github.com/moby/buildkit.git
synced 2026-08-09 01:01:08 +00:00
git: add sha256 commits support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package gitutil
|
||||
|
||||
func IsCommitSHA(str string) bool {
|
||||
if len(str) != 40 {
|
||||
if l := len(str); l != 40 && l != 64 {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
func TestIsCommitSHA(t *testing.T) {
|
||||
for truthy, commits := range map[bool][]string{
|
||||
true: {
|
||||
"01234567890abcdef01234567890abcdef012345", // 40 valid characters (SHA-1)
|
||||
"01234567890abcdef01234567890abcdef012345", // 40 valid characters (SHA-1)
|
||||
"01234567890abcdef01234567890abcdef01234567890abcdef01234567890ab", // 64 valid characters (SHA-256)
|
||||
},
|
||||
false: {
|
||||
"", // empty string
|
||||
@@ -24,8 +25,6 @@ func TestIsCommitSHA(t *testing.T) {
|
||||
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", // 64 invalid characters
|
||||
"01234567890abcdef01234567890abcdef01234567890abcdef01234567890abc", // 65 valid characters
|
||||
|
||||
// TODO: add SHA-256 support and move this up to the "true" section
|
||||
"01234567890abcdef01234567890abcdef01234567890abcdef01234567890ab", // 64 valid characters (SHA-256)
|
||||
},
|
||||
} {
|
||||
for _, commit := range commits {
|
||||
|
||||
Reference in New Issue
Block a user