summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-08-27 13:37:55 -0700
committerUnknwon <u@gogs.io>2016-08-27 13:37:55 -0700
commitc30b856d147dd895507c8f2334a11ed4baab6c18 (patch)
treeb0212b58f1026ba581f3f9c0ef1a366a5c4706df /models
parent13c106af7764a0b4757348ab4c82dbf9154ee11c (diff)
downloadgitea-c30b856d147dd895507c8f2334a11ed4baab6c18.tar.gz
gitea-c30b856d147dd895507c8f2334a11ed4baab6c18.zip
#3505 use user’s info for committer and author
Diffstat (limited to 'models')
-rw-r--r--models/repo.go5
-rw-r--r--models/repo_editor.go20
-rw-r--r--models/user.go2
-rw-r--r--models/wiki.go10
4 files changed, 23 insertions, 14 deletions
diff --git a/models/repo.go b/models/repo.go
index 14a5adeb55..1d425fe327 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -2303,7 +2303,10 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
if err = git.AddChanges(localPath, true); err != nil {
return fmt.Errorf("AddChanges: %v", err)
- } else if err = git.CommitChanges(localPath, message, doer.NewGitSig()); err != nil {
+ } else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
+ Committer: doer.NewGitSig(),
+ Message: message,
+ }); err != nil {
return fmt.Errorf("CommitChanges: %v", err)
} else if err = git.Push(localPath, "origin", branchName); err != nil {
return fmt.Errorf("Push: %v", err)
diff --git a/models/repo_editor.go b/models/repo_editor.go
index e89ad0a401..a773c8d36f 100644
--- a/models/repo_editor.go
+++ b/models/repo_editor.go
@@ -127,11 +127,11 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
if err = git.AddChanges(localPath, true); err != nil {
return fmt.Errorf("git add --all: %v", err)
- }
-
- signaure := doer.NewGitSig()
- if err = git.CommitChanges(localPath, opts.Message, signaure); err != nil {
- return fmt.Errorf("git commit -m %s --author='%s <%s>': %v", opts.Message, signaure.Name, signaure.Email, err)
+ } else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
+ Committer: doer.NewGitSig(),
+ Message: opts.Message,
+ }); err != nil {
+ return fmt.Errorf("CommitChanges: %v", err)
} else if err = git.Push(localPath, "origin", opts.NewBranch); err != nil {
return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
}
@@ -254,11 +254,11 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
if err = git.AddChanges(localPath, true); err != nil {
return fmt.Errorf("git add --all: %v", err)
- }
-
- signaure := doer.NewGitSig()
- if err = git.CommitChanges(localPath, opts.Message, signaure); err != nil {
- return fmt.Errorf("git commit -m %s --author='%s <%s>': %v", opts.Message, signaure.Name, signaure.Email, err)
+ } else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
+ Committer: doer.NewGitSig(),
+ Message: opts.Message,
+ }); err != nil {
+ return fmt.Errorf("CommitChanges: %v", err)
} else if err = git.Push(localPath, "origin", opts.Branch); err != nil {
return fmt.Errorf("git push origin %s: %v", opts.Branch, err)
}
diff --git a/models/user.go b/models/user.go
index 7ec5e12b2f..fa6bbacb7c 100644
--- a/models/user.go
+++ b/models/user.go
@@ -308,7 +308,7 @@ func (u *User) GetFollowing(page int) ([]*User, error) {
// NewGitSig generates and returns the signature of given user.
func (u *User) NewGitSig() *git.Signature {
return &git.Signature{
- Name: u.Name,
+ Name: u.DisplayName(),
Email: u.Email,
When: time.Now(),
}
diff --git a/models/wiki.go b/models/wiki.go
index 2f57eadda6..f62cd2ac79 100644
--- a/models/wiki.go
+++ b/models/wiki.go
@@ -129,7 +129,10 @@ func (repo *Repository) updateWikiPage(doer *User, oldTitle, title, content, mes
}
if err = git.AddChanges(localPath, true); err != nil {
return fmt.Errorf("AddChanges: %v", err)
- } else if err = git.CommitChanges(localPath, message, doer.NewGitSig()); err != nil {
+ } else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
+ Committer: doer.NewGitSig(),
+ Message: message,
+ }); err != nil {
return fmt.Errorf("CommitChanges: %v", err)
} else if err = git.Push(localPath, "origin", "master"); err != nil {
return fmt.Errorf("Push: %v", err)
@@ -165,7 +168,10 @@ func (repo *Repository) DeleteWikiPage(doer *User, title string) (err error) {
if err = git.AddChanges(localPath, true); err != nil {
return fmt.Errorf("AddChanges: %v", err)
- } else if err = git.CommitChanges(localPath, message, doer.NewGitSig()); err != nil {
+ } else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
+ Committer: doer.NewGitSig(),
+ Message: message,
+ }); err != nil {
return fmt.Errorf("CommitChanges: %v", err)
} else if err = git.Push(localPath, "origin", "master"); err != nil {
return fmt.Errorf("Push: %v", err)