Browse Source

commit format improved

pull/31/head
Lunny Xiao 11 years ago
parent
commit
1fb457ac1f
  1. 11
      models/action.go
  2. 5
      update.go

11
models/action.go

@ -5,6 +5,7 @@
package models package models
import ( import (
"encoding/json"
"time" "time"
) )
@ -45,13 +46,17 @@ func (a Action) GetRepoName() string {
// CommitRepoAction records action for commit repository. // CommitRepoAction records action for commit repository.
func CommitRepoAction(userId int64, userName string, func CommitRepoAction(userId int64, userName string,
repoId int64, repoName string, msg string) error { repoId int64, repoName string, commits [][]string) error {
_, err := orm.InsertOne(&Action{ bs, err := json.Marshal(commits)
if err != nil {
return err
}
_, err = orm.InsertOne(&Action{
UserId: userId, UserId: userId,
ActUserId: userId, ActUserId: userId,
ActUserName: userName, ActUserName: userName,
OpType: OP_COMMIT_REPO, OpType: OP_COMMIT_REPO,
Content: msg, Content: string(bs),
RepoId: repoId, RepoId: repoId,
RepoName: repoName, RepoName: repoName,
}) })

5
update.go

@ -47,6 +47,7 @@ func runUpdate(*cli.Context) {
if err != nil { if err != nil {
return return
} }
sUserId, err := strconv.Atoi(userId) sUserId, err := strconv.Atoi(userId)
if err != nil { if err != nil {
log.Error("runUpdate.Parse userId: %v", err) log.Error("runUpdate.Parse userId: %v", err)
@ -57,8 +58,10 @@ func runUpdate(*cli.Context) {
log.Error("runUpdate.Parse repoId: %v", err) log.Error("runUpdate.Parse repoId: %v", err)
return return
} }
commits := make([][]string, 0)
commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
if err = models.CommitRepoAction(int64(sUserId), userName, 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) log.Error("runUpdate.models.CommitRepoAction: %v", err)
} }
} }

Loading…
Cancel
Save