diff options
author | Unknwon <u@gogs.io> | 2017-02-16 16:33:49 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-16 16:33:49 -0500 |
commit | d521e716dd59617dbbb637a3e8028bf4a5c6f849 (patch) | |
tree | 24ba49f7b169a16c3e1f12ed880bda58a6ac6c58 /models | |
parent | 3b49a99b6088f2b1e1ba7539b4a69930dfb6de16 (diff) |
refactoring: SSH and HTTP push procees is now unified
We used to handle SSH and HTTP push separately which produces
duplicated code, but now with post-receive hook, the process
is unified to one single place and much cleaner.
Thus, UpdateTask struct is removed.
Narrow down the range of Git HTTP routes to reduce condufsing
HTTP Basic Authentication window popup on browser.
By detecting <old-commit, new-commit, ref-name> inside post-receive
hook, Git HTTP doesn't need to read the whole content body anymore,
which completely solve the RAM problem reported in #636.
Diffstat (limited to 'models')
-rw-r--r-- | models/access.go | 2 | ||||
-rw-r--r-- | models/action.go | 2 | ||||
-rw-r--r-- | models/models.go | 3 | ||||
-rw-r--r-- | models/update.go | 38 |
4 files changed, 6 insertions, 39 deletions
diff --git a/models/access.go b/models/access.go index 43a51775..0b114376 100644 --- a/models/access.go +++ b/models/access.go @@ -86,7 +86,7 @@ func AccessLevel(u *User, repo *Repository) (AccessMode, error) { func hasAccess(e Engine, u *User, repo *Repository, testMode AccessMode) (bool, error) { mode, err := accessLevel(e, u, repo) - return testMode <= mode, err + return mode >= testMode, err } // HasAccess returns true if someone has the request access level. User can be nil! diff --git a/models/action.go b/models/action.go index 37103523..ab8d9167 100644 --- a/models/action.go +++ b/models/action.go @@ -468,7 +468,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { } if err = UpdateIssuesCommit(pusher, repo, opts.Commits.Commits); err != nil { - log.Error(4, "UpdateIssuesCommit: %v", err) + log.Error(2, "UpdateIssuesCommit: %v", err) } } diff --git a/models/models.go b/models/models.go index 7b32f8bd..30110225 100644 --- a/models/models.go +++ b/models/models.go @@ -66,7 +66,7 @@ func init() { new(Issue), new(PullRequest), new(Comment), new(Attachment), new(IssueUser), new(Label), new(IssueLabel), new(Milestone), new(Mirror), new(Release), new(LoginSource), new(Webhook), - new(UpdateTask), new(HookTask), + new(HookTask), new(Team), new(OrgUser), new(TeamUser), new(TeamRepo), new(Notice), new(EmailAddress)) @@ -254,7 +254,6 @@ func GetStatistic() (stats Statistic) { stats.Counter.Label, _ = x.Count(new(Label)) stats.Counter.HookTask, _ = x.Count(new(HookTask)) stats.Counter.Team, _ = x.Count(new(Team)) - stats.Counter.UpdateTask, _ = x.Count(new(UpdateTask)) stats.Counter.Attachment, _ = x.Count(new(Attachment)) return } diff --git a/models/update.go b/models/update.go index 18d6c9dc..507150be 100644 --- a/models/update.go +++ b/models/update.go @@ -15,38 +15,6 @@ import ( git "github.com/gogits/git-module" ) -type UpdateTask struct { - ID int64 `xorm:"pk autoincr"` - UUID string `xorm:"index"` - RefName string - OldCommitID string - NewCommitID string -} - -func AddUpdateTask(task *UpdateTask) error { - _, err := x.Insert(task) - return err -} - -// GetUpdateTaskByUUID returns update task by given UUID. -func GetUpdateTaskByUUID(uuid string) (*UpdateTask, error) { - task := &UpdateTask{ - UUID: uuid, - } - has, err := x.Get(task) - if err != nil { - return nil, err - } else if !has { - return nil, ErrUpdateTaskNotExist{uuid} - } - return task, nil -} - -func DeleteUpdateTaskByUUID(uuid string) error { - _, err := x.Delete(&UpdateTask{UUID: uuid}) - return err -} - // CommitToPushCommit transforms a git.Commit to PushCommit type. func CommitToPushCommit(commit *git.Commit) *PushCommit { return &PushCommit{ @@ -74,13 +42,13 @@ func ListToPushCommits(l *list.List) *PushCommits { } type PushUpdateOptions struct { + OldCommitID string + NewCommitID string + RefFullName string PusherID int64 PusherName string RepoUserName string RepoName string - RefFullName string - OldCommitID string - NewCommitID string } // PushUpdate must be called for any push actions in order to |