update.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package models
  2. import (
  3. "container/list"
  4. "os/exec"
  5. "strings"
  6. "github.com/gogits/git"
  7. "github.com/gogits/gogs/modules/base"
  8. qlog "github.com/qiniu/log"
  9. )
  10. func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) {
  11. isNew := strings.HasPrefix(oldCommitId, "0000000")
  12. if isNew &&
  13. strings.HasPrefix(newCommitId, "0000000") {
  14. qlog.Fatal("old rev and new rev both 000000")
  15. }
  16. f := RepoPath(userName, repoName)
  17. gitUpdate := exec.Command("git", "update-server-info")
  18. gitUpdate.Dir = f
  19. gitUpdate.Run()
  20. repo, err := git.OpenRepository(f)
  21. if err != nil {
  22. qlog.Fatalf("runUpdate.Open repoId: %v", err)
  23. }
  24. newCommit, err := repo.GetCommit(newCommitId)
  25. if err != nil {
  26. qlog.Fatalf("runUpdate GetCommit of newCommitId: %v", err)
  27. return
  28. }
  29. var l *list.List
  30. // if a new branch
  31. if isNew {
  32. l, err = newCommit.CommitsBefore()
  33. if err != nil {
  34. qlog.Fatalf("Find CommitsBefore erro: %v", err)
  35. }
  36. } else {
  37. l, err = newCommit.CommitsBeforeUntil(oldCommitId)
  38. if err != nil {
  39. qlog.Fatalf("Find CommitsBeforeUntil erro: %v", err)
  40. return
  41. }
  42. }
  43. if err != nil {
  44. qlog.Fatalf("runUpdate.Commit repoId: %v", err)
  45. }
  46. repos, err := GetRepositoryByName(userId, repoName)
  47. if err != nil {
  48. qlog.Fatalf("runUpdate.GetRepositoryByName userId: %v", err)
  49. }
  50. commits := make([]*base.PushCommit, 0)
  51. var maxCommits = 3
  52. var actEmail string
  53. for e := l.Front(); e != nil; e = e.Next() {
  54. commit := e.Value.(*git.Commit)
  55. if actEmail == "" {
  56. actEmail = commit.Committer.Email
  57. }
  58. commits = append(commits,
  59. &base.PushCommit{commit.Id.String(),
  60. commit.Message(),
  61. commit.Author.Email,
  62. commit.Author.Name})
  63. if len(commits) >= maxCommits {
  64. break
  65. }
  66. }
  67. //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
  68. if err = CommitRepoAction(userId, userName, actEmail,
  69. repos.Id, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil {
  70. qlog.Fatalf("runUpdate.models.CommitRepoAction: %v", err)
  71. }
  72. }
PANIC: session(release): write data/sessions/5/0/50f2b8da472bd9e1: no space left on device

PANIC

session(release): write data/sessions/5/0/50f2b8da472bd9e1: no space left on device
github.com/go-macaron/session@v0.0.0-20190805070824-1a3cdc6f5659/session.go:199 (0x8b2934)
gopkg.in/macaron.v1@v1.3.9/context.go:79 (0x83d0a0)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/context.go:112 (0x84fdb5)
gopkg.in/macaron.v1@v1.3.9/recovery.go:161 (0x84fda8)
gopkg.in/macaron.v1@v1.3.9/logger.go:40 (0x840c73)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/router.go:187 (0x850fc6)
gopkg.in/macaron.v1@v1.3.9/router.go:303 (0x8493e5)
gopkg.in/macaron.v1@v1.3.9/macaron.go:220 (0x841fca)
net/http/server.go:2836 (0x7a79b2)
net/http/server.go:1924 (0x7a341b)
runtime/asm_amd64.s:1373 (0x46f9f0)