summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2018-09-07 05:06:09 +0300
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-09-06 22:06:09 -0400
commitfa4663e61e39f0cef225ea92235a16e7da977b08 (patch)
tree7a4a784295c5b0efea8319352ca9987e4abe4148 /vendor
parentbf552761894dee08f734d91f5c8175cd0cb2f9f5 (diff)
downloadgitea-fa4663e61e39f0cef225ea92235a16e7da977b08.tar.gz
gitea-fa4663e61e39f0cef225ea92235a16e7da977b08.zip
Add push webhook support for mirrored repositories (#4127)
Diffstat (limited to 'vendor')
-rw-r--r--vendor/code.gitea.io/git/commit.go24
-rw-r--r--vendor/code.gitea.io/git/repo_commit.go17
2 files changed, 37 insertions, 4 deletions
diff --git a/vendor/code.gitea.io/git/commit.go b/vendor/code.gitea.io/git/commit.go
index 299a2381b6..5e8c91d303 100644
--- a/vendor/code.gitea.io/git/commit.go
+++ b/vendor/code.gitea.io/git/commit.go
@@ -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
+}
diff --git a/vendor/code.gitea.io/git/repo_commit.go b/vendor/code.gitea.io/git/repo_commit.go
index 1acdfffb34..d5cab8f873 100644
--- a/vendor/code.gitea.io/git/repo_commit.go
+++ b/vendor/code.gitea.io/git/repo_commit.go
@@ -78,7 +78,7 @@ l:
}
commit.Committer = sig
case "gpgsig":
- sig, err := newGPGSignatureFromCommitline(data, nextline+spacepos+1)
+ sig, err := newGPGSignatureFromCommitline(data, nextline+spacepos+1, false)
if err != nil {
return nil, err
}
@@ -86,7 +86,20 @@ l:
}
nextline += eol + 1
case eol == 0:
- commit.CommitMessage = string(data[nextline+1:])
+ cm := string(data[nextline+1:])
+
+ // Tag GPG signatures are stored below the commit message
+ sigindex := strings.Index(cm, "-----BEGIN PGP SIGNATURE-----")
+ if sigindex != -1 {
+ sig, err := newGPGSignatureFromCommitline(data, (nextline+1)+sigindex, true)
+ if err == nil && sig != nil {
+ // remove signature from commit message
+ cm = cm[:sigindex-1]
+ commit.Signature = sig
+ }
+ }
+
+ commit.CommitMessage = cm
break l
default:
break l