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.

69 lines
1.7 KiB

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