Mirror fix on #248
This commit is contained in:
parent
fb53cc4fa8
commit
47d29a1ee0
|
@ -42,5 +42,7 @@ func runUpdate(c *cli.Context) {
|
||||||
repoUserName := os.Getenv("repoUserName")
|
repoUserName := os.Getenv("repoUserName")
|
||||||
repoName := os.Getenv("repoName")
|
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())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.4.5.0622 Alpha"
|
const APP_VER = "0.4.5.0623 Alpha"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -6,6 +6,7 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -15,11 +16,11 @@ import (
|
||||||
"github.com/gogits/gogs/modules/log"
|
"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")
|
isNew := strings.HasPrefix(oldCommitId, "0000000")
|
||||||
if isNew &&
|
if isNew &&
|
||||||
strings.HasPrefix(newCommitId, "0000000") {
|
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)
|
f := RepoPath(repoUserName, repoName)
|
||||||
|
@ -31,18 +32,17 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
|
||||||
isDel := strings.HasPrefix(newCommitId, "0000000")
|
isDel := strings.HasPrefix(newCommitId, "0000000")
|
||||||
if isDel {
|
if isDel {
|
||||||
log.GitLogger.Info("del rev", refName, "from", userName+"/"+repoName+".git", "by", userId)
|
log.GitLogger.Info("del rev", refName, "from", userName+"/"+repoName+".git", "by", userId)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
repo, err := git.OpenRepository(f)
|
repo, err := git.OpenRepository(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("runUpdate.Open repoId: %v", err)
|
return fmt.Errorf("runUpdate.Open repoId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommit, err := repo.GetCommit(newCommitId)
|
newCommit, err := repo.GetCommit(newCommitId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("runUpdate GetCommit of newCommitId: %v", err)
|
return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var l *list.List
|
var l *list.List
|
||||||
|
@ -50,28 +50,27 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
|
||||||
if isNew {
|
if isNew {
|
||||||
l, err = newCommit.CommitsBefore()
|
l, err = newCommit.CommitsBefore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("Find CommitsBefore erro: %v", err)
|
return fmt.Errorf("Find CommitsBefore erro: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l, err = newCommit.CommitsBeforeUntil(oldCommitId)
|
l, err = newCommit.CommitsBeforeUntil(oldCommitId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("Find CommitsBeforeUntil erro: %v", err)
|
return fmt.Errorf("Find CommitsBeforeUntil erro: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("runUpdate.Commit repoId: %v", err)
|
return fmt.Errorf("runUpdate.Commit repoId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ru, err := GetUserByName(repoUserName)
|
ru, err := GetUserByName(repoUserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("runUpdate.GetUserByName: %v", err)
|
return fmt.Errorf("runUpdate.GetUserByName: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
repos, err := GetRepositoryByName(ru.Id, repoName)
|
repos, err := GetRepositoryByName(ru.Id, repoName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.GitLogger.Fatal("runUpdate.GetRepositoryByName userId: %v", err)
|
return fmt.Errorf("runUpdate.GetRepositoryByName userId: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
commits := make([]*base.PushCommit, 0)
|
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()})
|
//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
|
||||||
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
|
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
|
||||||
repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,10 @@ func Http(ctx *middleware.Context, params martini.Params) {
|
||||||
newCommitId := fields[1]
|
newCommitId := fields[1]
|
||||||
refName := fields[2]
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.4.5.0622 Alpha
|
0.4.5.0623 Alpha
|
Loading…
Reference in New Issue