aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-10-10 21:40:51 -0400
committerUnknwon <joe2010xtmf@163.com>2014-10-10 21:40:51 -0400
commitb2632dec099cb2727933149d2d59cc5e46baa15f (patch)
tree0339b98dcd6a38bf9a02e3681d4e22a024ceaa9f /models
parent54930c001df8316d8dfda450b5c39379df2cc1b1 (diff)
downloadgitea-b2632dec099cb2727933149d2d59cc5e46baa15f.tar.gz
gitea-b2632dec099cb2727933149d2d59cc5e46baa15f.zip
Page: Compare 2 commits
Diffstat (limited to 'models')
-rw-r--r--models/action.go18
-rw-r--r--models/update.go9
2 files changed, 12 insertions, 15 deletions
diff --git a/models/action.go b/models/action.go
index 4203ead38e..ef111e67a4 100644
--- a/models/action.go
+++ b/models/action.go
@@ -181,13 +181,19 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
commit = &base.PushCommits{}
}
- refName := git.RefEndName(refFullName)
+ repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
+ // if not the first commit, set the compareUrl
+ if !strings.HasPrefix(oldCommitId, "0000000") {
+ commit.CompareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
+ }
bs, err := json.Marshal(commit)
if err != nil {
return errors.New("action.CommitRepoAction(json): " + err.Error())
}
+ refName := git.RefEndName(refFullName)
+
// Change repository bare status and update last updated time.
repo, err := GetRepositoryByName(repoUserId, repoName)
if err != nil {
@@ -211,7 +217,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error())
}
- //qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName)
// New push event hook.
if err := repo.GetOwner(); err != nil {
@@ -237,13 +242,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
return nil
}
- repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
- compareUrl := ""
- // if not the first commit, set the compareUrl
- if !strings.HasPrefix(oldCommitId, "0000000") {
- compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
- }
-
pusher_email, pusher_name := "", ""
pusher, err := GetUserByName(userName)
if err == nil {
@@ -293,7 +291,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
},
Before: oldCommitId,
After: newCommitId,
- CompareUrl: compareUrl,
+ CompareUrl: commit.CompareUrl,
}
for _, w := range ws {
diff --git a/models/update.go b/models/update.go
index d939a90874..33b7733e18 100644
--- a/models/update.go
+++ b/models/update.go
@@ -106,7 +106,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil {
- log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
+ log.GitLogger.Fatal(4, "CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
}
return err
}
@@ -116,8 +116,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err)
}
+ // Push new branch.
var l *list.List
- // if a new branch
if isNew {
l, err = newCommit.CommitsBefore()
if err != nil {
@@ -134,7 +134,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
return fmt.Errorf("runUpdate.Commit repoId: %v", err)
}
- // if commits push
+ // Push commits.
commits := make([]*base.PushCommit, 0)
var actEmail string
for e := l.Front(); e != nil; e = e.Next() {
@@ -153,9 +153,8 @@ 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}, oldCommitId, newCommitId); err != nil {
+ repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil {
return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
}
return nil