Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

update.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2014 The Gogs 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 cmd
  5. import (
  6. "os"
  7. "strconv"
  8. "github.com/codegangsta/cli"
  9. "github.com/gogits/gogs/models"
  10. "github.com/gogits/gogs/modules/log"
  11. )
  12. var CmdUpdate = cli.Command{
  13. Name: "update",
  14. Usage: "This command should only be called by SSH shell",
  15. Description: `Update get pushed info and insert into database`,
  16. Action: runUpdate,
  17. Flags: []cli.Flag{},
  18. }
  19. func runUpdate(c *cli.Context) {
  20. cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
  21. if cmd == "" {
  22. return
  23. }
  24. setup("update.log")
  25. args := c.Args()
  26. if len(args) != 3 {
  27. log.GitLogger.Fatal("received less 3 parameters")
  28. } else if args[0] == "" {
  29. log.GitLogger.Fatal("refName is empty, shouldn't use")
  30. }
  31. userName := os.Getenv("userName")
  32. userId, _ := strconv.ParseInt(os.Getenv("userId"), 10, 64)
  33. repoUserName := os.Getenv("repoUserName")
  34. repoName := os.Getenv("repoName")
  35. if err := models.Update(args[0], args[1], args[2], userName, repoUserName, repoName, userId); err != nil {
  36. log.GitLogger.Fatal(err.Error())
  37. }
  38. }