diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-16 23:02:59 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-16 23:02:59 +0800 |
commit | 1fb457ac1f46ef07557f5c8c5b84438f2325a5cf (patch) | |
tree | 3c0c1004f71c1eb574044f82fc62d5406c4a043e | |
parent | f824d6a4b11d4d8ddc82d54c5183934b465afbd3 (diff) | |
download | gitea-1fb457ac1f46ef07557f5c8c5b84438f2325a5cf.tar.gz gitea-1fb457ac1f46ef07557f5c8c5b84438f2325a5cf.zip |
commit format improved
-rw-r--r-- | models/action.go | 11 | ||||
-rw-r--r-- | update.go | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/models/action.go b/models/action.go index 9e075646a6..ceee9997a4 100644 --- a/models/action.go +++ b/models/action.go @@ -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, }) @@ -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) } } |