diff --git a/models/action.go b/models/action.go index ec1f630a8..b1ccfe074 100644 --- a/models/action.go +++ b/models/action.go @@ -473,7 +473,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err } // Check for dependencies, if there aren't any, close it - canbeClosed := IssueNoDependenciesLeft(issue) + canbeClosed := IssueNoDependenciesLeft(issue.ID) if canbeClosed { if err = issue.ChangeStatus(doer, repo, true); err != nil { diff --git a/models/issue_comment.go b/models/issue_comment.go index 6930c62e2..b0dd338bd 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -79,25 +79,25 @@ const ( // Comment represents a comment in commit and issue page. type Comment struct { - ID int64 `xorm:"pk autoincr"` - Type CommentType - PosterID int64 `xorm:"INDEX"` - Poster *User `xorm:"-"` - IssueID int64 `xorm:"INDEX"` - LabelID int64 - Label *Label `xorm:"-"` - OldMilestoneID int64 - MilestoneID int64 - OldMilestone *Milestone `xorm:"-"` - Milestone *Milestone `xorm:"-"` - OldAssigneeID int64 - AssigneeID int64 - Assignee *User `xorm:"-"` - OldAssignee *User `xorm:"-"` - OldTitle string - NewTitle string + ID int64 `xorm:"pk autoincr"` + Type CommentType + PosterID int64 `xorm:"INDEX"` + Poster *User `xorm:"-"` + IssueID int64 `xorm:"INDEX"` + LabelID int64 + Label *Label `xorm:"-"` + OldMilestoneID int64 + MilestoneID int64 + OldMilestone *Milestone `xorm:"-"` + Milestone *Milestone `xorm:"-"` + OldAssigneeID int64 + AssigneeID int64 + Assignee *User `xorm:"-"` + OldAssignee *User `xorm:"-"` + OldTitle string + NewTitle string DependentIssueID int64 - DependentIssue *Issue `xorm:"-"` + DependentIssue *Issue `xorm:"-"` CommitID int64 Line int64 @@ -322,23 +322,23 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err } comment := &Comment{ - Type: opts.Type, - PosterID: opts.Doer.ID, - Poster: opts.Doer, - IssueID: opts.Issue.ID, - LabelID: LabelID, - OldMilestoneID: opts.OldMilestoneID, - MilestoneID: opts.MilestoneID, - OldAssigneeID: opts.OldAssigneeID, - AssigneeID: opts.AssigneeID, - CommitID: opts.CommitID, - CommitSHA: opts.CommitSHA, - Line: opts.LineNum, - Content: opts.Content, - OldTitle: opts.OldTitle, - NewTitle: opts.NewTitle, - DependentIssue: opts.DependentIssue, - DependentIssueID: opts.DependentIssue.ID, + Type: opts.Type, + PosterID: opts.Doer.ID, + Poster: opts.Doer, + IssueID: opts.Issue.ID, + LabelID: LabelID, + OldMilestoneID: opts.OldMilestoneID, + MilestoneID: opts.MilestoneID, + OldAssigneeID: opts.OldAssigneeID, + AssigneeID: opts.AssigneeID, + CommitID: opts.CommitID, + CommitSHA: opts.CommitSHA, + Line: opts.LineNum, + Content: opts.Content, + OldTitle: opts.OldTitle, + NewTitle: opts.NewTitle, + DependentIssue: opts.DependentIssue, + DependentIssueID: depId, } //fmt.Println(comment) @@ -528,22 +528,22 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep } return createComment(e, &CreateCommentOptions{ - Type: cType, - Doer: doer, - Repo: issue.Repo, - Issue: issue, + Type: cType, + Doer: doer, + Repo: issue.Repo, + Issue: issue, DependentIssue: dependantIssue, - Content: issue.Title, + Content: issue.Title, }) } // CreateCommentOptions defines options for creating comment type CreateCommentOptions struct { - Type CommentType - Doer *User - Repo *Repository - Issue *Issue - Label *Label + Type CommentType + Doer *User + Repo *Repository + Issue *Issue + Label *Label DependentIssue *Issue OldMilestoneID int64 diff --git a/models/issue_dependency.go b/models/issue_dependency.go index 0947f607f..de0b2caa9 100644 --- a/models/issue_dependency.go +++ b/models/issue_dependency.go @@ -13,7 +13,7 @@ type IssueDependency struct { ID int64 `xorm:"pk autoincr"` UserID int64 `xorm:"UNIQUE(watch) NOT NULL"` IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"` - DependencyID int64 `xorm:"UNIQUE(watch) NOT NULL"` + DependencyID int64 `xorm:"UNIQUE(watch) NOT NULL"` Created time.Time `xorm:"-"` CreatedUnix int64 `xorm:"NOT NULL"` Updated time.Time `xorm:"-"` diff --git a/models/repo.go b/models/repo.go index 66c34982c..be0916779 100644 --- a/models/repo.go +++ b/models/repo.go @@ -694,12 +694,12 @@ func (repo *Repository) getUsersWithAccessMode(e Engine, mode AccessMode) (_ []* } // Find all Dependencies an issue is blocked by -func (repo *Repository) BlockedByDependencies(issueID int64) (_ []*Issue, err error) { +func (repo *Repository) BlockedByDependencies(issueID int64) (_ []*Issue, err error) { issueDeps, err := repo.getBlockedByDependencies(x, issueID) var issueDepsFull = make([]*Issue, 0) - for _, issueDep := range issueDeps{ + for _, issueDep := range issueDeps { issueDetails, _ := getIssueByID(x, issueDep.DependencyID) issueDepsFull = append(issueDepsFull, issueDetails) } @@ -711,12 +711,12 @@ func (repo *Repository) BlockedByDependencies(issueID int64) (_ []*Issue, err e return issueDepsFull, nil } -func (repo *Repository) BlockingDependencies(issueID int64) (_ []*Issue, err error) { +func (repo *Repository) BlockingDependencies(issueID int64) (_ []*Issue, err error) { issueDeps, err := repo.getBlockingDependencies(x, issueID) var issueDepsFull = make([]*Issue, 0) - for _, issueDep := range issueDeps{ + for _, issueDep := range issueDeps { issueDetails, _ := getIssueByID(x, issueDep.IssueID) issueDepsFull = append(issueDepsFull, issueDetails) } @@ -727,6 +727,7 @@ func (repo *Repository) BlockingDependencies(issueID int64) (_ []*Issue, err er return issueDepsFull, nil } + // NextIssueIndex returns the next issue index // FIXME: should have a mutex to prevent producing same index for two issues that are created // closely enough. diff --git a/models/repo_unit.go b/models/repo_unit.go index cb9e8ca77..be8239ca4 100644 --- a/models/repo_unit.go +++ b/models/repo_unit.go @@ -150,7 +150,7 @@ func (r *RepoUnit) ExternalTrackerConfig() *ExternalTrackerConfig { } // IssueDependenciesConfig returns config for UnitTypeIssueDependencies -func (r *RepoUnit) IssueDependenciesConfig() *UnitConfig{ +func (r *RepoUnit) IssueDependenciesConfig() *UnitConfig { return r.Config.(*UnitConfig) } diff --git a/models/unit.go b/models/unit.go index 7dc348a58..876fb8ac8 100644 --- a/models/unit.go +++ b/models/unit.go @@ -9,14 +9,14 @@ type UnitType int // Enumerate all the unit types const ( - UnitTypeCode UnitType = iota + 1 // 1 code - UnitTypeIssues // 2 issues - UnitTypePullRequests // 3 PRs - UnitTypeReleases // 4 Releases - UnitTypeWiki // 5 Wiki - UnitTypeExternalWiki // 6 ExternalWiki - UnitTypeExternalTracker // 7 ExternalTracker - UnitTypeIssueDependencies // 8 Issue Dependencies + UnitTypeCode UnitType = iota + 1 // 1 code + UnitTypeIssues // 2 issues + UnitTypePullRequests // 3 PRs + UnitTypeReleases // 4 Releases + UnitTypeWiki // 5 Wiki + UnitTypeExternalWiki // 6 ExternalWiki + UnitTypeExternalTracker // 7 ExternalTracker + UnitTypeIssueDependencies // 8 Issue Dependencies ) var ( @@ -130,13 +130,13 @@ var ( // Units contains all the units Units = map[UnitType]Unit{ - UnitTypeCode: UnitCode, - UnitTypeIssues: UnitIssues, - UnitTypeExternalTracker: UnitExternalTracker, - UnitTypePullRequests: UnitPullRequests, - UnitTypeReleases: UnitReleases, - UnitTypeWiki: UnitWiki, - UnitTypeExternalWiki: UnitExternalWiki, + UnitTypeCode: UnitCode, + UnitTypeIssues: UnitIssues, + UnitTypeExternalTracker: UnitExternalTracker, + UnitTypePullRequests: UnitPullRequests, + UnitTypeReleases: UnitReleases, + UnitTypeWiki: UnitWiki, + UnitTypeExternalWiki: UnitExternalWiki, UnitTypeIssueDependencies: UnitIssueDependencies, } ) diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 106ddf6f5..b2236dd57 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -95,19 +95,18 @@ type RepoSettingForm struct { EnablePrune bool // Advanced settings - EnableWiki bool - EnableExternalWiki bool - ExternalWikiURL string - EnableIssues bool - EnableExternalTracker bool - ExternalTrackerURL string - TrackerURLFormat string - TrackerIssueStyle string - EnablePulls bool - EnableIssueDependencies bool + EnableWiki bool + EnableExternalWiki bool + ExternalWikiURL string + EnableIssues bool + EnableExternalTracker bool + ExternalTrackerURL string + TrackerURLFormat string + TrackerIssueStyle string + EnablePulls bool EnableTimetracker bool AllowOnlyContributorsToTrackTime bool - EnableIssueDependencies bool + EnableIssueDependencies bool } // Validate validates the fields diff --git a/routers/repo/issue.go b/routers/repo/issue.go index c14c1076a..454a7c5d9 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -684,8 +684,8 @@ func ViewIssue(ctx *context.Context) { ctx.Handle(500, "LoadAssignees", err) return } - } else if comment.Type == models.CommentTypeRemovedDependency || comment.Type == models.CommentTypeAddedDependency{ - if err = comment.LoadDepIssueDetails(); err != nil{ + } else if comment.Type == models.CommentTypeRemovedDependency || comment.Type == models.CommentTypeAddedDependency { + if err = comment.LoadDepIssueDetails(); err != nil { ctx.Handle(http.StatusInternalServerError, "LoadDepIssueDetails", err) return } @@ -920,12 +920,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { !(issue.IsPull && issue.PullRequest.HasMerged) { // Check for open dependencies - if form.Status == "close"{ + if form.Status == "close" { - canbeClosed := models.IssueNoDependenciesLeft(issue) + canbeClosed := models.IssueNoDependenciesLeft(issue.ID) if !canbeClosed { - if issue.IsPull{ + if issue.IsPull { ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!") ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index)) } else { diff --git a/routers/repo/issue_dependency_add.go b/routers/repo/issue_dependency_add.go index f4ce3c299..630772a98 100644 --- a/routers/repo/issue_dependency_add.go +++ b/routers/repo/issue_dependency_add.go @@ -45,7 +45,7 @@ func AddDependency(c *context.Context) { } // Check if issue and dependency is the same - if dep.Index == issueIndex{ + if dep.Index == issueIndex { c.Flash.Error(c.Tr("issues.dependency.add_error_same_issue")) } else { diff --git a/routers/repo/issue_dependency_remove.go b/routers/repo/issue_dependency_remove.go index 2885673c8..f20eb94a4 100644 --- a/routers/repo/issue_dependency_remove.go +++ b/routers/repo/issue_dependency_remove.go @@ -36,7 +36,7 @@ func RemoveDependency(c *context.Context) { return } - if depType != 1 && depType != 2{ + if depType != 1 && depType != 2 { c.Handle(http.StatusBadRequest, "GetDependecyType", nil) return } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index caeddaa00..77f178daa 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -428,7 +428,7 @@ func MergePullRequest(ctx *context.Context) { pr.Issue = issue pr.Issue.Repo = ctx.Repo.Repository - canbeClosed := models.IssueNoDependenciesLeft(issue) + canbeClosed := models.IssueNoDependenciesLeft(issue.ID) if !canbeClosed { ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!") diff --git a/routers/repo/setting.go b/routers/repo/setting.go index dcba5eb5f..9296c3f6f 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -219,7 +219,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { }) } - if form.EnableIssueDependencies{ + if form.EnableIssueDependencies { units = append(units, models.RepoUnit{ RepoID: repo.ID, Type: models.UnitTypeIssueDependencies, diff --git a/vendor/github.com/go-xorm/xorm/circle.yml b/vendor/github.com/go-xorm/xorm/circle.yml index 19e99f2ba..69fc7164b 100644 --- a/vendor/github.com/go-xorm/xorm/circle.yml +++ b/vendor/github.com/go-xorm/xorm/circle.yml @@ -35,4 +35,4 @@ test: - cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./mysql.sh - cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./postgres.sh post: - - bash <(curl -s https://codecov.io/bash) + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file