Skip to content

Commit

Permalink
Ensure that GIT_AUTHOR_NAME etc. are valid for git
Browse files Browse the repository at this point in the history
see #5774

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath committed Jan 20, 2019
1 parent 78e27c2 commit d0d28c9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions modules/uploader/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@ func (t *TemporaryUploadRepository) WriteTree() (string, error) {
// CommitTree creates a commit from a given tree for the user with provided message
func (t *TemporaryUploadRepository) CommitTree(doer *models.User, treeHash string, message string) (string, error) {
commitTimeStr := time.Now().Format(time.UnixDate)
sig := doer.NewGitSig()

// FIXME: Should we add SSH_ORIGINAL_COMMAND to this
// Because this may call hooks we should pass in the environment
env := append(os.Environ(),
"GIT_AUTHOR_NAME="+doer.DisplayName(),
"GIT_AUTHOR_EMAIL="+doer.Email,
"GIT_AUTHOR_NAME="+sig.Name,
"GIT_AUTHOR_EMAIL="+sig.Email,
"GIT_AUTHOR_DATE="+commitTimeStr,
"GIT_COMMITTER_NAME="+doer.DisplayName(),
"GIT_COMMITTER_EMAIL="+doer.Email,
"GIT_COMMITTER_NAME="+sig.Name,
"GIT_COMMITTER_EMAIL="+sig.Email,
"GIT_COMMITTER_DATE="+commitTimeStr,
)
commitHash, stderr, err := process.GetManager().ExecDirEnv(5*time.Minute,
Expand All @@ -235,13 +236,15 @@ func (t *TemporaryUploadRepository) Push(doer *models.User, commitHash string, b
isWiki = "true"
}

sig := doer.NewGitSig()

// FIXME: Should we add SSH_ORIGINAL_COMMAND to this
// Because calls hooks we need to pass in the environment
env := append(os.Environ(),
"GIT_AUTHOR_NAME="+doer.DisplayName(),
"GIT_AUTHOR_EMAIL="+doer.Email,
"GIT_COMMITTER_NAME="+doer.DisplayName(),
"GIT_COMMITTER_EMAIL="+doer.Email,
"GIT_AUTHOR_NAME="+sig.Name,
"GIT_AUTHOR_EMAIL="+sig.Email,
"GIT_COMMITTER_NAME="+sig.Name,
"GIT_COMMITTER_EMAIL="+sig.Email,
models.EnvRepoName+"="+t.repo.Name,
models.EnvRepoUsername+"="+t.repo.OwnerName,
models.EnvRepoIsWiki+"="+isWiki,
Expand Down

0 comments on commit d0d28c9

Please sign in to comment.