diff options
author | skyblue <ssx205@gmail.com> | 2014-03-23 22:40:35 +0800 |
---|---|---|
committer | skyblue <ssx205@gmail.com> | 2014-03-23 22:40:35 +0800 |
commit | 4bac3616055110da6f060e98174bc2381ef91286 (patch) | |
tree | 6fc09df1b6bef1a73fac40771702ae5f4f71f1d4 /models/action.go | |
parent | b9302749ddc0e0a10911a83bf80e165b792c8c1e (diff) | |
parent | f7f175a0793a53f3c50d20d89e324a610f94c442 (diff) |
merge with branch master
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/models/action.go b/models/action.go index 107d4b10..11749293 100644 --- a/models/action.go +++ b/models/action.go @@ -7,6 +7,9 @@ package models import ( "encoding/json" "time" + + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" ) // Operation types of user action. @@ -28,7 +31,8 @@ type Action struct { ActUserName string // Action user name. RepoId int64 RepoName string - Content string + RefName string + Content string `xorm:"TEXT"` Created time.Time `xorm:"created"` } @@ -44,13 +48,17 @@ func (a Action) GetRepoName() string { return a.RepoName } +func (a Action) GetBranch() string { + return a.RefName +} + func (a Action) GetContent() string { return a.Content } // CommitRepoAction records action for commit repository. func CommitRepoAction(userId int64, userName string, - repoId int64, repoName string, commits [][]string) error { + repoId int64, repoName string, refName string, commits *base.PushCommits) error { bs, err := json.Marshal(commits) if err != nil { return err @@ -76,9 +84,22 @@ func CommitRepoAction(userId int64, userName string, Content: string(bs), RepoId: repoId, RepoName: repoName, + RefName: refName, }) return err } + + // Update repository last update time. + repo, err := GetRepositoryByName(userId, repoName) + if err != nil { + return err + } + repo.IsBare = false + if err = UpdateRepository(repo); err != nil { + return err + } + + log.Trace("action.CommitRepoAction: %d/%s", userId, repo.LowerName) return nil } @@ -92,6 +113,8 @@ func NewRepoAction(user *User, repo *Repository) error { RepoId: repo.Id, RepoName: repo.Name, }) + + log.Trace("action.NewRepoAction: %s/%s", user.LowerName, repo.LowerName) return err } |