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.

update.go 2.0 kB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 main
  5. import (
  6. "fmt"
  7. "os"
  8. "github.com/codegangsta/cli"
  9. "github.com/gogits/gogs/modules/log"
  10. )
  11. var CmdUpdate = cli.Command{
  12. Name: "update",
  13. Usage: "This command just should be called by ssh shell",
  14. Description: `
  15. gogs serv provide access auth for repositories`,
  16. Action: runUpdate,
  17. Flags: []cli.Flag{},
  18. }
  19. // for command: ./gogs update
  20. func runUpdate(c *cli.Context) {
  21. level := "0"
  22. os.MkdirAll("log", os.ModePerm)
  23. log.NewLogger(10000, "file", fmt.Sprintf(`{"level":%s,"filename":"%s"}`, level, "log/serv.log"))
  24. log.Info("start update logging...")
  25. //w, _ := os.Create("update.log")
  26. //log.SetOutput(w)
  27. for i, arg := range c.Args() {
  28. log.Info("%d : %s", i, arg)
  29. }
  30. /*userName := os.Getenv("userName")
  31. userId := os.Getenv("userId")
  32. repoId := os.Getenv("repoId")
  33. repoName := os.Getenv("repoName")
  34. f := models.RepoPath(userName, repoName)
  35. repo, err := git.OpenRepository(f)
  36. if err != nil {
  37. log.Error("runUpdate.Open repoId: %v", err)
  38. return
  39. }
  40. ref, err := repo.LookupReference("HEAD")
  41. if err != nil {
  42. log.Error("runUpdate.Ref repoId: %v", err)
  43. return
  44. }
  45. lastCommit, err := repo.LookupCommit(ref.Oid)
  46. if err != nil {
  47. log.Error("runUpdate.Commit repoId: %v", err)
  48. return
  49. }
  50. sUserId, err := strconv.Atoi(userId)
  51. if err != nil {
  52. log.Error("runUpdate.Parse userId: %v", err)
  53. return
  54. }
  55. sRepoId, err := strconv.Atoi(repoId)
  56. if err != nil {
  57. log.Error("runUpdate.Parse repoId: %v", err)
  58. return
  59. }
  60. commits := make([][]string, 0)
  61. commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
  62. if err = models.CommitRepoAction(int64(sUserId), userName,
  63. int64(sRepoId), repoName, commits); err != nil {
  64. log.Error("runUpdate.models.CommitRepoAction: %v", err)
  65. } else {
  66. l := exec.Command("exec", "git", "update-server-info")
  67. l.Run()
  68. }*/
  69. }