Add push webhook support for mirrored repositories (#4127)
This commit is contained in:
parent
bf55276189
commit
fa4663e61e
8 changed files with 257 additions and 19 deletions
24
vendor/code.gitea.io/git/commit.go
generated
vendored
24
vendor/code.gitea.io/git/commit.go
generated
vendored
|
@ -34,14 +34,18 @@ type CommitGPGSignature struct {
|
|||
}
|
||||
|
||||
// similar to https://github.com/git/git/blob/3bc53220cb2dcf709f7a027a3f526befd021d858/commit.c#L1128
|
||||
func newGPGSignatureFromCommitline(data []byte, signatureStart int) (*CommitGPGSignature, error) {
|
||||
func newGPGSignatureFromCommitline(data []byte, signatureStart int, tag bool) (*CommitGPGSignature, error) {
|
||||
sig := new(CommitGPGSignature)
|
||||
signatureEnd := bytes.LastIndex(data, []byte("-----END PGP SIGNATURE-----"))
|
||||
if signatureEnd == -1 {
|
||||
return nil, fmt.Errorf("end of commit signature not found")
|
||||
}
|
||||
sig.Signature = strings.Replace(string(data[signatureStart:signatureEnd+27]), "\n ", "\n", -1)
|
||||
sig.Payload = string(data[:signatureStart-8]) + string(data[signatureEnd+27:])
|
||||
if tag {
|
||||
sig.Payload = string(data[:signatureStart-1])
|
||||
} else {
|
||||
sig.Payload = string(data[:signatureStart-8]) + string(data[signatureEnd+27:])
|
||||
}
|
||||
return sig, nil
|
||||
}
|
||||
|
||||
|
@ -274,3 +278,19 @@ func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
|
|||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.
|
||||
func GetFullCommitID(repoPath, shortID string) (string, error) {
|
||||
if len(shortID) >= 40 {
|
||||
return shortID, nil
|
||||
}
|
||||
|
||||
commitID, err := NewCommand("rev-parse", shortID).RunInDir(repoPath)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "exit status 128") {
|
||||
return "", ErrNotExist{shortID, ""}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimSpace(commitID), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue