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

helper_environment.go 997B

12345678910111213141516171819202122232425262728293031323334353637
  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. // We should add "SSH_ORIGINAL_COMMAND=gitea-internal",
  18. // once we have hook and pushing infrastructure working correctly
  19. return append(os.Environ(),
  20. "GIT_AUTHOR_NAME="+sig.Name,
  21. "GIT_AUTHOR_EMAIL="+sig.Email,
  22. "GIT_COMMITTER_NAME="+sig.Name,
  23. "GIT_COMMITTER_EMAIL="+sig.Email,
  24. EnvRepoName+"="+repo.Name,
  25. EnvRepoUsername+"="+repo.MustOwnerName(),
  26. EnvRepoIsWiki+"="+isWiki,
  27. EnvPusherName+"="+doer.Name,
  28. EnvPusherID+"="+fmt.Sprintf("%d", doer.ID),
  29. ProtectedBranchRepoID+"="+fmt.Sprintf("%d", repo.ID),
  30. )
  31. }