From fac9bd4d139055e0c3be25b5e4294c22a56e2339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 3 Jan 2016 13:31:21 +0100 Subject: [PATCH] Apply suggestions by github.com/mvdan/interfacer --- models/issue.go | 27 +++++++++++++-------------- models/repo.go | 2 +- models/ssh_key.go | 2 +- models/wiki.go | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/models/issue.go b/models/issue.go index 22ea72512..b98e7f91e 100644 --- a/models/issue.go +++ b/models/issue.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "io" - "mime/multipart" "os" "path" "strings" @@ -126,7 +125,7 @@ func (i *Issue) HasLabel(labelID int64) bool { return i.hasLabel(x, labelID) } -func (i *Issue) addLabel(e *xorm.Session, label *Label) error { +func (i *Issue) addLabel(e Engine, label *Label) error { return newIssueLabel(e, i, label) } @@ -162,7 +161,7 @@ func (i *Issue) GetLabels() error { return i.getLabels(x) } -func (i *Issue) removeLabel(e *xorm.Session, label *Label) error { +func (i *Issue) removeLabel(e Engine, label *Label) error { return deleteIssueLabel(e, i, label) } @@ -218,7 +217,7 @@ func (i *Issue) ReadBy(uid int64) error { return UpdateIssueUserByRead(uid, i.ID) } -func (i *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (err error) { +func (i *Issue) changeStatus(e Engine, doer *User, isClosed bool) (err error) { if i.IsClosed == isClosed { return nil } @@ -283,7 +282,7 @@ func (i *Issue) GetPullRequest() (err error) { } // It's caller's responsibility to create action. -func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64, uuids []string, isPull bool) (err error) { +func newIssue(e Engine, repo *Repository, issue *Issue, labelIDs []int64, uuids []string, isPull bool) (err error) { if _, err = e.Insert(issue); err != nil { return err } @@ -554,7 +553,7 @@ type IssueUser struct { IsClosed bool } -func newIssueUsers(e *xorm.Session, repo *Repository, issue *Issue) error { +func newIssueUsers(e Engine, repo *Repository, issue *Issue) error { users, err := repo.GetAssignees() if err != nil { return err @@ -876,7 +875,7 @@ func UpdateIssueUsersByStatus(issueID int64, isClosed bool) error { return updateIssueUsersByStatus(x, issueID, isClosed) } -func updateIssueUserByAssignee(e *xorm.Session, issue *Issue) (err error) { +func updateIssueUserByAssignee(e Engine, issue *Issue) (err error) { if _, err = e.Exec("UPDATE `issue_user` SET is_assigned=? WHERE issue_id=?", false, issue.ID); err != nil { return err } @@ -1071,7 +1070,7 @@ func HasIssueLabel(issueID, labelID int64) bool { return hasIssueLabel(x, issueID, labelID) } -func newIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) { +func newIssueLabel(e Engine, issue *Issue, label *Label) (err error) { if _, err = e.Insert(&IssueLabel{ IssueID: issue.ID, LabelID: label.ID, @@ -1111,7 +1110,7 @@ func GetIssueLabels(issueID int64) ([]*IssueLabel, error) { return getIssueLabels(x, issueID) } -func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) { +func deleteIssueLabel(e Engine, issue *Issue, label *Label) (err error) { if _, err = e.Delete(&IssueLabel{ IssueID: issue.ID, LabelID: label.ID, @@ -1316,7 +1315,7 @@ func ChangeMilestoneStatus(m *Milestone, isClosed bool) (err error) { return sess.Commit() } -func changeMilestoneIssueStats(e *xorm.Session, issue *Issue) error { +func changeMilestoneIssueStats(e Engine, issue *Issue) error { if issue.MilestoneID == 0 { return nil } @@ -1353,7 +1352,7 @@ func ChangeMilestoneIssueStats(issue *Issue) (err error) { return sess.Commit() } -func changeMilestoneAssign(e *xorm.Session, oldMid int64, issue *Issue) error { +func changeMilestoneAssign(e Engine, oldMid int64, issue *Issue) error { if oldMid > 0 { m, err := getMilestoneByID(e, oldMid) if err != nil { @@ -1549,7 +1548,7 @@ func (c *Comment) EventTag() string { return "event-" + com.ToStr(c.ID) } -func createComment(e *xorm.Session, u *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content, commitSHA string, uuids []string) (_ *Comment, err error) { +func createComment(e Engine, u *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content, commitSHA string, uuids []string) (_ *Comment, err error) { comment := &Comment{ PosterID: u.Id, Type: cmtType, @@ -1631,7 +1630,7 @@ func createComment(e *xorm.Session, u *User, repo *Repository, issue *Issue, com return comment, nil } -func createStatusComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue) (*Comment, error) { +func createStatusComment(e Engine, doer *User, repo *Repository, issue *Issue) (*Comment, error) { cmtType := COMMENT_TYPE_CLOSE if !issue.IsClosed { cmtType = COMMENT_TYPE_REOPEN @@ -1728,7 +1727,7 @@ func (attach *Attachment) LocalPath() string { } // NewAttachment creates a new attachment object. -func NewAttachment(name string, buf []byte, file multipart.File) (_ *Attachment, err error) { +func NewAttachment(name string, buf []byte, file io.Reader) (_ *Attachment, err error) { attach := &Attachment{ UUID: gouuid.NewV4().String(), Name: name, diff --git a/models/repo.go b/models/repo.go index e53d80657..0415314d6 100644 --- a/models/repo.go +++ b/models/repo.go @@ -855,7 +855,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C return nil } -func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) { +func createRepository(e Engine, u *User, repo *Repository) (err error) { if err = IsUsableName(repo.Name); err != nil { return err } diff --git a/models/ssh_key.go b/models/ssh_key.go index f0db4de43..56c414c11 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -562,7 +562,7 @@ func checkDeployKey(e Engine, keyID, repoID int64, name string) error { } // addDeployKey adds new key-repo relation. -func addDeployKey(e *xorm.Session, keyID, repoID int64, name, fingerprint string) (*DeployKey, error) { +func addDeployKey(e Engine, keyID, repoID int64, name, fingerprint string) (*DeployKey, error) { if err := checkDeployKey(e, keyID, repoID, name); err != nil { return nil, err } diff --git a/models/wiki.go b/models/wiki.go index e3eb1f680..2bd548b22 100644 --- a/models/wiki.go +++ b/models/wiki.go @@ -7,12 +7,12 @@ package models import ( "fmt" "io/ioutil" + "net/url" "os" "path" "path/filepath" "strings" "sync" - "net/url" "github.com/Unknwon/com"