diff --git a/models/issue_comment.go b/models/issue_comment.go index b0dd338bd..c1e2285fc 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -275,7 +275,7 @@ func (c *Comment) LoadAssignees() error { return nil } -// Load Dependent Issue Details +// LoadDepIssueDetails loads Dependent Issue Details func (c *Comment) LoadDepIssueDetails() error { var err error if c.DependentIssueID > 0 { @@ -316,9 +316,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err LabelID = opts.Label.ID } - var depId int64 = 0 + var depID int64 if opts.DependentIssue != nil { - depId = opts.DependentIssue.ID + depID = opts.DependentIssue.ID } comment := &Comment{ @@ -338,7 +338,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err OldTitle: opts.OldTitle, NewTitle: opts.NewTitle, DependentIssue: opts.DependentIssue, - DependentIssueID: depId, + DependentIssueID: depID, } //fmt.Println(comment) diff --git a/models/issue_dependency.go b/models/issue_dependency.go index de0b2caa9..df4e119a8 100644 --- a/models/issue_dependency.go +++ b/models/issue_dependency.go @@ -43,50 +43,50 @@ func (iw *IssueDependency) BeforeUpdate() { } // CreateIssueDependency creates a new dependency for an issue -func CreateIssueDependency(user *User, issue, dep *Issue) (err error, exists bool, depExists bool) { +func CreateIssueDependency(user *User, issue, dep *Issue) (exists bool, depExists bool, err error) { sess := x.NewSession() // TODO: Move this to the appropriate place err = x.Sync(new(IssueDependency)) if err != nil { - return err, exists, false + return exists, false, err } // Check if it aleready exists exists, err = issueDepExists(x, issue.ID, dep.ID) if err != nil { - return err, exists, false + return exists, false, err } // If it not exists, create it, otherwise show an error message if !exists { - newId := new(IssueDependency) - newId.UserID = user.ID - newId.IssueID = issue.ID - newId.DependencyID = dep.ID + newID := new(IssueDependency) + newID.UserID = user.ID + newID.IssueID = issue.ID + newID.DependencyID = dep.ID - if _, err := x.Insert(newId); err != nil { - return err, exists, false + if _, err := x.Insert(newID); err != nil { + return exists, false, err } // Add comment referencing the new dependency _, err = createIssueDependencyComment(sess, user, issue, dep, true) if err != nil { - return err, exists, false + return exists, false, err } // Create a new comment for the dependent issue _, err = createIssueDependencyComment(sess, user, dep, issue, true) if err != nil { - return err, exists, false + return exists, false, err } } - return nil, exists, false + return exists, false, err } -// Removes a dependency from an issue +// RemoveIssueDependency removes a dependency from an issue func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType int64) (err error) { sess := x.NewSession() @@ -153,7 +153,7 @@ func issueDepExists(e Engine, issueID int64, depID int64) (exists bool, err erro return } -// check if issue can be closed +// IssueNoDependenciesLeft checks if issue can be closed func IssueNoDependenciesLeft(issueID int64) bool { var issueDeps []IssueDependency diff --git a/models/repo.go b/models/repo.go index be0916779..37ef57062 100644 --- a/models/repo.go +++ b/models/repo.go @@ -693,7 +693,7 @@ func (repo *Repository) getUsersWithAccessMode(e Engine, mode AccessMode) (_ []* return users, nil } -// Find all Dependencies an issue is blocked by +// BlockedByDependencies finds all Dependencies an issue is blocked by func (repo *Repository) BlockedByDependencies(issueID int64) (_ []*Issue, err error) { issueDeps, err := repo.getBlockedByDependencies(x, issueID) @@ -711,6 +711,7 @@ func (repo *Repository) BlockedByDependencies(issueID int64) (_ []*Issue, err er return issueDepsFull, nil } +// BlockingDependencies returns all blocking dependencies func (repo *Repository) BlockingDependencies(issueID int64) (_ []*Issue, err error) { issueDeps, err := repo.getBlockingDependencies(x, issueID) diff --git a/routers/repo/issue_dependency_add.go b/routers/repo/issue_dependency_add.go index 630772a98..ee74401db 100644 --- a/routers/repo/issue_dependency_add.go +++ b/routers/repo/issue_dependency_add.go @@ -13,7 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" ) -// Adds new dependencies +// AddDependency adds new dependencies func AddDependency(c *context.Context) { // TODO: should should an issue only have dependencies in it's own repo? @@ -49,7 +49,7 @@ func AddDependency(c *context.Context) { c.Flash.Error(c.Tr("issues.dependency.add_error_same_issue")) } else { - err, exists, depExists := models.CreateIssueDependency(c.User, issue, dep) + exists, depExists, err := models.CreateIssueDependency(c.User, issue, dep) if err != nil { c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err) return diff --git a/routers/repo/issue_dependency_remove.go b/routers/repo/issue_dependency_remove.go index f20eb94a4..7234564b0 100644 --- a/routers/repo/issue_dependency_remove.go +++ b/routers/repo/issue_dependency_remove.go @@ -13,7 +13,7 @@ import ( "code.gitea.io/gitea/modules/context" ) -// IssueWatch sets issue watching +// RemoveDependency removes the dependency func RemoveDependency(c *context.Context) { depID, err := strconv.ParseInt(c.Req.PostForm.Get("removeDependencyID"), 10, 64) if err != nil {