Skip to content

Commit d0d28c9

Browse files
committed
Ensure that GIT_AUTHOR_NAME etc. are valid for git
see #5774 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 78e27c2 commit d0d28c9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/uploader/repo.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,16 @@ func (t *TemporaryUploadRepository) WriteTree() (string, error) {
206206
// CommitTree creates a commit from a given tree for the user with provided message
207207
func (t *TemporaryUploadRepository) CommitTree(doer *models.User, treeHash string, message string) (string, error) {
208208
commitTimeStr := time.Now().Format(time.UnixDate)
209+
sig := doer.NewGitSig()
209210

210211
// FIXME: Should we add SSH_ORIGINAL_COMMAND to this
211212
// Because this may call hooks we should pass in the environment
212213
env := append(os.Environ(),
213-
"GIT_AUTHOR_NAME="+doer.DisplayName(),
214-
"GIT_AUTHOR_EMAIL="+doer.Email,
214+
"GIT_AUTHOR_NAME="+sig.Name,
215+
"GIT_AUTHOR_EMAIL="+sig.Email,
215216
"GIT_AUTHOR_DATE="+commitTimeStr,
216-
"GIT_COMMITTER_NAME="+doer.DisplayName(),
217-
"GIT_COMMITTER_EMAIL="+doer.Email,
217+
"GIT_COMMITTER_NAME="+sig.Name,
218+
"GIT_COMMITTER_EMAIL="+sig.Email,
218219
"GIT_COMMITTER_DATE="+commitTimeStr,
219220
)
220221
commitHash, stderr, err := process.GetManager().ExecDirEnv(5*time.Minute,
@@ -235,13 +236,15 @@ func (t *TemporaryUploadRepository) Push(doer *models.User, commitHash string, b
235236
isWiki = "true"
236237
}
237238

239+
sig := doer.NewGitSig()
240+
238241
// FIXME: Should we add SSH_ORIGINAL_COMMAND to this
239242
// Because calls hooks we need to pass in the environment
240243
env := append(os.Environ(),
241-
"GIT_AUTHOR_NAME="+doer.DisplayName(),
242-
"GIT_AUTHOR_EMAIL="+doer.Email,
243-
"GIT_COMMITTER_NAME="+doer.DisplayName(),
244-
"GIT_COMMITTER_EMAIL="+doer.Email,
244+
"GIT_AUTHOR_NAME="+sig.Name,
245+
"GIT_AUTHOR_EMAIL="+sig.Email,
246+
"GIT_COMMITTER_NAME="+sig.Name,
247+
"GIT_COMMITTER_EMAIL="+sig.Email,
245248
models.EnvRepoName+"="+t.repo.Name,
246249
models.EnvRepoUsername+"="+t.repo.OwnerName,
247250
models.EnvRepoIsWiki+"="+isWiki,

0 commit comments

Comments
 (0)