summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-22 04:44:57 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-22 04:44:57 -0400
commit932f717adb1cb1738415fcddaf5eb3c0e4a60fc2 (patch)
tree60a13dd51c6016901f0f262b00635efa25bf1a93 /models
parentf219ddcf4ef13b9d5de129da4eb2b56dbc899d61 (diff)
downloadgitea-932f717adb1cb1738415fcddaf5eb3c0e4a60fc2.tar.gz
gitea-932f717adb1cb1738415fcddaf5eb3c0e4a60fc2.zip
Fixing bug
Diffstat (limited to 'models')
-rw-r--r--models/action.go10
-rw-r--r--models/repo.go9
-rw-r--r--models/user.go4
3 files changed, 18 insertions, 5 deletions
diff --git a/models/action.go b/models/action.go
index 107d4b1057..89751b9779 100644
--- a/models/action.go
+++ b/models/action.go
@@ -79,6 +79,16 @@ func CommitRepoAction(userId int64, userName string,
})
return err
}
+
+ // Update repository last update time.
+ repo, err := GetRepositoryByName(userId, repoName)
+ if err != nil {
+ return err
+ }
+ repo.Updated = time.Now()
+ if err = UpdateRepository(repo); err != nil {
+ return err
+ }
return nil
}
diff --git a/models/repo.go b/models/repo.go
index 918e5dc84c..6a764e6c31 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -358,6 +358,11 @@ func RepoPath(userName, repoName string) string {
return filepath.Join(UserPath(userName), repoName+".git")
}
+func UpdateRepository(repo *Repository) error {
+ _, err := orm.Id(repo.Id).UseBool().Update(repo)
+ return err
+}
+
// DeleteRepository deletes a repository for a user or orgnaztion.
func DeleteRepository(userId, repoId int64, userName string) (err error) {
repo := &Repository{Id: repoId, OwnerId: userId}
@@ -402,9 +407,9 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) {
}
// GetRepositoryByName returns the repository by given name under user if exists.
-func GetRepositoryByName(user *User, repoName string) (*Repository, error) {
+func GetRepositoryByName(userId int64, repoName string) (*Repository, error) {
repo := &Repository{
- OwnerId: user.Id,
+ OwnerId: userId,
LowerName: strings.ToLower(repoName),
}
has, err := orm.Get(repo)
diff --git a/models/user.go b/models/user.go
index 3c11091285..d6dc041490 100644
--- a/models/user.go
+++ b/models/user.go
@@ -279,9 +279,7 @@ func GetUserByName(name string) (*User, error) {
if len(name) == 0 {
return nil, ErrUserNotExist
}
- user := &User{
- LowerName: strings.ToLower(name),
- }
+ user := &User{LowerName: strings.ToLower(name)}
has, err := orm.Get(user)
if err != nil {
return nil, err