Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Okstad <pokstad@gitlab.com>2020-09-15 21:56:24 +0300
committerPaul Okstad <pokstad@gitlab.com>2020-09-15 21:56:24 +0300
commit0cc72a02229617905e560886227b3743527cd197 (patch)
tree46006a4e10123496359f773e3d0526e501e2e281 /cmd/gitaly-git2go
parent7de73fe9bdced68051087ea6f33dff61c4ed3573 (diff)
parentf7bb67439a8e6a1bcd0b2a3e632407dab6479dcf (diff)
Merge branch 'pks-git2go-merge-operation-service' into 'master'
Port OperationService.UserMergeBranch to Go Closes #3069 See merge request gitlab-org/gitaly!2540
Diffstat (limited to 'cmd/gitaly-git2go')
-rw-r--r--cmd/gitaly-git2go/merge.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/cmd/gitaly-git2go/merge.go b/cmd/gitaly-git2go/merge.go
index 1e5c13aa4..7eb6c691a 100644
--- a/cmd/gitaly-git2go/merge.go
+++ b/cmd/gitaly-git2go/merge.go
@@ -6,6 +6,7 @@ import (
"errors"
"flag"
"fmt"
+ "strings"
"time"
git "github.com/libgit2/git2go/v30"
@@ -74,12 +75,23 @@ func lookupCommit(repo *git.Repository, ref string) (*git.Commit, error) {
return commit, nil
}
+func sanitizeSignatureInfo(info string) string {
+ return strings.Map(func(r rune) rune {
+ switch r {
+ case '<', '>', '\n':
+ return -1
+ default:
+ return r
+ }
+ }, info)
+}
+
func (cmd *mergeSubcommand) Run() error {
if err := cmd.verifyOptions(); err != nil {
return fmt.Errorf("invalid options: %w", err)
}
- var date time.Time
+ var date time.Time = time.Now()
if cmd.authorDate != "" {
var err error
date, err = time.Parse("Mon Jan 2 15:04:05 2006 -0700", cmd.authorDate)
@@ -118,8 +130,8 @@ func (cmd *mergeSubcommand) Run() error {
}
committer := git.Signature{
- Name: cmd.authorName,
- Email: cmd.authorMail,
+ Name: sanitizeSignatureInfo(cmd.authorName),
+ Email: sanitizeSignatureInfo(cmd.authorMail),
When: date,
}