]> source.dussan.org Git - gitea.git/commitdiff
commit format improved
authorLunny Xiao <xiaolunwen@gmail.com>
Sun, 16 Mar 2014 15:02:59 +0000 (23:02 +0800)
committerLunny Xiao <xiaolunwen@gmail.com>
Sun, 16 Mar 2014 15:02:59 +0000 (23:02 +0800)
models/action.go
update.go

index 9e075646a6f05deb6684c3a2741e810098ae9e22..ceee9997a45434646afe33813f8b83cd4d13906e 100644 (file)
@@ -5,6 +5,7 @@
 package models
 
 import (
+       "encoding/json"
        "time"
 )
 
@@ -45,13 +46,17 @@ func (a Action) GetRepoName() string {
 
 // CommitRepoAction records action for commit repository.
 func CommitRepoAction(userId int64, userName string,
-       repoId int64, repoName string, msg string) error {
-       _, err := orm.InsertOne(&Action{
+       repoId int64, repoName string, commits [][]string) error {
+       bs, err := json.Marshal(commits)
+       if err != nil {
+               return err
+       }
+       _, err = orm.InsertOne(&Action{
                UserId:      userId,
                ActUserId:   userId,
                ActUserName: userName,
                OpType:      OP_COMMIT_REPO,
-               Content:     msg,
+               Content:     string(bs),
                RepoId:      repoId,
                RepoName:    repoName,
        })
index 477989e861475fd8a32045e475e610b84c249aaf..23d8fb028a9f2ea15cf039b66a76c60a35ae7382 100644 (file)
--- a/update.go
+++ b/update.go
@@ -47,6 +47,7 @@ func runUpdate(*cli.Context) {
        if err != nil {
                return
        }
+
        sUserId, err := strconv.Atoi(userId)
        if err != nil {
                log.Error("runUpdate.Parse userId: %v", err)
@@ -57,8 +58,10 @@ func runUpdate(*cli.Context) {
                log.Error("runUpdate.Parse repoId: %v", err)
                return
        }
+       commits := make([][]string, 0)
+       commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
        if err = models.CommitRepoAction(int64(sUserId), userName,
-               int64(sRepoId), repoName, lastCommit.Message()); err != nil {
+               int64(sRepoId), repoName, commits); err != nil {
                log.Error("runUpdate.models.CommitRepoAction: %v", err)
        }
 }