summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-06-23 16:22:34 -0400
committerUnknown <joe2010xtmf@163.com>2014-06-23 16:22:34 -0400
commit47d29a1ee027734dcbbd1a6ed4d8ff3dde1a789b (patch)
treea1b8b4902b9c9c9c0dda2bfe28eb51f7ed6aa50a
parentfb53cc4fa82bbbbba4b8b0281d5f5657b1a6fafc (diff)
downloadgitea-47d29a1ee027734dcbbd1a6ed4d8ff3dde1a789b.tar.gz
gitea-47d29a1ee027734dcbbd1a6ed4d8ff3dde1a789b.zip
Mirror fix on #248
-rw-r--r--cmd/update.go4
-rw-r--r--gogs.go2
-rw-r--r--models/update.go26
-rw-r--r--routers/repo/http.go5
-rw-r--r--templates/VERSION2
5 files changed, 22 insertions, 17 deletions
diff --git a/cmd/update.go b/cmd/update.go
index d0e0acded9..c030b6cfb2 100644
--- a/cmd/update.go
+++ b/cmd/update.go
@@ -42,5 +42,7 @@ func runUpdate(c *cli.Context) {
repoUserName := os.Getenv("repoUserName")
repoName := os.Getenv("repoName")
- models.Update(args[0], args[1], args[2], userName, repoUserName, repoName, userId)
+ if err := models.Update(args[0], args[1], args[2], userName, repoUserName, repoName, userId); err != nil {
+ log.GitLogger.Fatal(err.Error())
+ }
}
diff --git a/gogs.go b/gogs.go
index 03c2860165..a39d2d4338 100644
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.4.5.0622 Alpha"
+const APP_VER = "0.4.5.0623 Alpha"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/update.go b/models/update.go
index 5675a94cf4..3328f2213f 100644
--- a/models/update.go
+++ b/models/update.go
@@ -6,6 +6,7 @@ package models
import (
"container/list"
+ "fmt"
"os/exec"
"strings"
@@ -15,11 +16,11 @@ import (
"github.com/gogits/gogs/modules/log"
)
-func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) {
+func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) error {
isNew := strings.HasPrefix(oldCommitId, "0000000")
if isNew &&
strings.HasPrefix(newCommitId, "0000000") {
- log.GitLogger.Fatal("old rev and new rev both 000000")
+ return fmt.Errorf("old rev and new rev both 000000")
}
f := RepoPath(repoUserName, repoName)
@@ -31,18 +32,17 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
isDel := strings.HasPrefix(newCommitId, "0000000")
if isDel {
log.GitLogger.Info("del rev", refName, "from", userName+"/"+repoName+".git", "by", userId)
- return
+ return nil
}
repo, err := git.OpenRepository(f)
if err != nil {
- log.GitLogger.Fatal("runUpdate.Open repoId: %v", err)
+ return fmt.Errorf("runUpdate.Open repoId: %v", err)
}
newCommit, err := repo.GetCommit(newCommitId)
if err != nil {
- log.GitLogger.Fatal("runUpdate GetCommit of newCommitId: %v", err)
- return
+ return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err)
}
var l *list.List
@@ -50,28 +50,27 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
if isNew {
l, err = newCommit.CommitsBefore()
if err != nil {
- log.GitLogger.Fatal("Find CommitsBefore erro: %v", err)
+ return fmt.Errorf("Find CommitsBefore erro: %v", err)
}
} else {
l, err = newCommit.CommitsBeforeUntil(oldCommitId)
if err != nil {
- log.GitLogger.Fatal("Find CommitsBeforeUntil erro: %v", err)
- return
+ return fmt.Errorf("Find CommitsBeforeUntil erro: %v", err)
}
}
if err != nil {
- log.GitLogger.Fatal("runUpdate.Commit repoId: %v", err)
+ return fmt.Errorf("runUpdate.Commit repoId: %v", err)
}
ru, err := GetUserByName(repoUserName)
if err != nil {
- log.GitLogger.Fatal("runUpdate.GetUserByName: %v", err)
+ return fmt.Errorf("runUpdate.GetUserByName: %v", err)
}
repos, err := GetRepositoryByName(ru.Id, repoName)
if err != nil {
- log.GitLogger.Fatal("runUpdate.GetRepositoryByName userId: %v", err)
+ return fmt.Errorf("runUpdate.GetRepositoryByName userId: %v", err)
}
commits := make([]*base.PushCommit, 0)
@@ -95,6 +94,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil {
- log.GitLogger.Fatal("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
+ return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
}
+ return nil
}
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 5915e8761e..d2bff29973 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -141,7 +141,10 @@ func Http(ctx *middleware.Context, params martini.Params) {
newCommitId := fields[1]
refName := fields[2]
- models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id)
+ if err = models.Update(refName, oldCommitId, newCommitId, authUsername, username, reponame, authUser.Id); err != nil {
+ log.GitLogger.Error(err.Error())
+ return
+ }
}
}
}
diff --git a/templates/VERSION b/templates/VERSION
index 414dc2efe9..ca3b3f1ba5 100644
--- a/templates/VERSION
+++ b/templates/VERSION
@@ -1 +1 @@
-0.4.5.0622 Alpha \ No newline at end of file
+0.4.5.0623 Alpha \ No newline at end of file