Make API "compare" accept commit IDs (#32801)

This commit is contained in:
wxiaoguang 2024-12-12 16:10:09 +08:00 committed by GitHub
parent 01b1896bf5
commit 22bf2ca6ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 154 additions and 124 deletions

View file

@ -474,3 +474,17 @@ func (c *Commit) GetRepositoryDefaultPublicGPGKey(forceUpdate bool) (*GPGSetting
}
return c.repo.GetDefaultPublicGPGKey(forceUpdate)
}
func IsStringLikelyCommitID(objFmt ObjectFormat, s string, minLength ...int) bool {
minLen := util.OptionalArg(minLength, objFmt.FullLength())
if len(s) < minLen || len(s) > objFmt.FullLength() {
return false
}
for _, c := range s {
isHex := (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')
if !isHex {
return false
}
}
return true
}