You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

helper_environment.go 908 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. import (
  6. "fmt"
  7. "os"
  8. "strings"
  9. )
  10. // PushingEnvironment returns an os environment to allow hooks to work on push
  11. func PushingEnvironment(doer *User, repo *Repository) []string {
  12. isWiki := "false"
  13. if strings.HasSuffix(repo.Name, ".wiki") {
  14. isWiki = "true"
  15. }
  16. sig := doer.NewGitSig()
  17. return append(os.Environ(),
  18. "GIT_AUTHOR_NAME="+sig.Name,
  19. "GIT_AUTHOR_EMAIL="+sig.Email,
  20. "GIT_COMMITTER_NAME="+sig.Name,
  21. "GIT_COMMITTER_EMAIL="+sig.Email,
  22. EnvRepoName+"="+repo.Name,
  23. EnvRepoUsername+"="+repo.OwnerName,
  24. EnvRepoIsWiki+"="+isWiki,
  25. EnvPusherName+"="+doer.Name,
  26. EnvPusherID+"="+fmt.Sprintf("%d", doer.ID),
  27. ProtectedBranchRepoID+"="+fmt.Sprintf("%d", repo.ID),
  28. "SSH_ORIGINAL_COMMAND=gitea-internal",
  29. )
  30. }