summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-24 22:30:50 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-24 22:30:50 +0800
commit0e28dcdac402b3bfc8336fe250e3418939467208 (patch)
treef16788377cf724e7d6ea28301f2876632a34d3dc /models
parent48ea9b12f65e21c8584eb89224bda4ad6c635847 (diff)
parentc9e1eb0a0d9e6bdafa158442158c762b7f188177 (diff)
downloadgitea-0e28dcdac402b3bfc8336fe250e3418939467208.tar.gz
gitea-0e28dcdac402b3bfc8336fe250e3418939467208.zip
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'models')
-rw-r--r--models/action.go11
-rw-r--r--models/issue.go19
-rw-r--r--models/repo.go2
-rw-r--r--models/user.go5
4 files changed, 30 insertions, 7 deletions
diff --git a/models/action.go b/models/action.go
index 1174929354..44d7aea8ca 100644
--- a/models/action.go
+++ b/models/action.go
@@ -59,14 +59,18 @@ func (a Action) GetContent() string {
// CommitRepoAction records action for commit repository.
func CommitRepoAction(userId int64, userName string,
repoId int64, repoName string, refName string, commits *base.PushCommits) error {
+ log.Trace("action.CommitRepoAction: %d/%s", userId, repoName)
+
bs, err := json.Marshal(commits)
if err != nil {
+ log.Error("action.CommitRepoAction(json): %d/%s", userId, repoName)
return err
}
// Add feeds for user self and all watchers.
watches, err := GetWatches(repoId)
if err != nil {
+ log.Error("action.CommitRepoAction(get watches): %d/%s", userId, repoName)
return err
}
watches = append(watches, Watch{UserId: userId})
@@ -86,20 +90,23 @@ func CommitRepoAction(userId int64, userName string,
RepoName: repoName,
RefName: refName,
})
+ if err != nil {
+ log.Error("action.CommitRepoAction(notify watches): %d/%s", userId, repoName)
+ }
return err
}
// Update repository last update time.
repo, err := GetRepositoryByName(userId, repoName)
if err != nil {
+ log.Error("action.CommitRepoAction(GetRepositoryByName): %d/%s", userId, repoName)
return err
}
repo.IsBare = false
if err = UpdateRepository(repo); err != nil {
+ log.Error("action.CommitRepoAction(UpdateRepository): %d/%s", userId, repoName)
return err
}
-
- log.Trace("action.CommitRepoAction: %d/%s", userId, repo.LowerName)
return nil
}
diff --git a/models/issue.go b/models/issue.go
index 929567b1b7..fe43a94b59 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -58,6 +58,7 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co
Content: content,
}
_, err = orm.Insert(issue)
+ // TODO: newIssueAction
return issue, err
}
@@ -67,9 +68,9 @@ func GetIssueCount(repoId int64) (int64, error) {
}
// GetIssueById returns issue object by given id.
-func GetIssueById(id int64) (*Issue, error) {
- issue := new(Issue)
- has, err := orm.Id(id).Get(issue)
+func GetIssueByIndex(repoId, index int64) (*Issue, error) {
+ issue := &Issue{RepoId: repoId, Index: index}
+ has, err := orm.Get(issue)
if err != nil {
return nil, err
} else if !has {
@@ -126,6 +127,18 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed,
return issues, err
}
+// UpdateIssue updates information of issue.
+func UpdateIssue(issue *Issue) error {
+ _, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index})
+ return err
+}
+
+func CloseIssue() {
+}
+
+func ReopenIssue() {
+}
+
// Label represents a list of labels of repository for issues.
type Label struct {
Id int64
diff --git a/models/repo.go b/models/repo.go
index 14bcfcca4d..6cbfaf1059 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -389,7 +389,7 @@ func UpdateRepository(repo *Repository) error {
repo.Website = repo.Website[:255]
}
- _, err := orm.Id(repo.Id).UseBool().Cols("description", "website").Update(repo)
+ _, err := orm.Id(repo.Id).AllCols().Update(repo)
return err
}
diff --git a/models/user.go b/models/user.go
index 9333d1ee67..6ca16ec32e 100644
--- a/models/user.go
+++ b/models/user.go
@@ -72,6 +72,9 @@ func (user *User) HomeLink() string {
// AvatarLink returns the user gravatar link.
func (user *User) AvatarLink() string {
+ if base.Service.EnableCacheAvatar {
+ return "/avatar/" + user.Avatar
+ }
return "http://1.gravatar.com/avatar/" + user.Avatar
}
@@ -208,7 +211,7 @@ func UpdateUser(user *User) (err error) {
user.Website = user.Website[:255]
}
- _, err = orm.Id(user.Id).UseBool().Cols("website", "location").Update(user)
+ _, err = orm.Id(user.Id).AllCols().Update(user)
return err
}