}
// Check for open dependencies
- if isClosed && issue.Repo.IsDependenciesEnabled() {
+ if isClosed && issue.Repo.isDependenciesEnabled(e) {
// only check if dependencies are enabled and we're about to close an issue, otherwise reopening an issue would fail when there are unsatisfied dependencies
- noDeps, err := IssueNoDependenciesLeft(issue)
+ noDeps, err := issueNoDependenciesLeft(e, issue)
if err != nil {
return err
}
if err = sess.Commit(); err != nil {
return fmt.Errorf("Commit: %v", err)
}
+ sess.Close()
mode, _ := AccessLevel(issue.Poster.ID, issue.Repo)
if issue.IsPull {
// IssueNoDependenciesLeft checks if issue can be closed
func IssueNoDependenciesLeft(issue *Issue) (bool, error) {
+ return issueNoDependenciesLeft(x, issue)
+}
- exists, err := x.
+func issueNoDependenciesLeft(e Engine, issue *Issue) (bool, error) {
+ exists, err := e.
Table("issue_dependency").
Select("issue.*").
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
// IsDependenciesEnabled returns if dependecies are enabled and returns the default setting if not set.
func (repo *Repository) IsDependenciesEnabled() bool {
+ return repo.isDependenciesEnabled(x)
+}
+
+func (repo *Repository) isDependenciesEnabled(e Engine) bool {
var u *RepoUnit
var err error
- if u, err = repo.GetUnit(UnitTypeIssues); err != nil {
+ if u, err = repo.getUnit(e, UnitTypeIssues); err != nil {
log.Trace("%s", err)
return setting.Service.DefaultEnableDependencies
}
// GetUnit returns a RepoUnit object
func (repo *Repository) GetUnit(tp UnitType) (*RepoUnit, error) {
- if err := repo.getUnits(x); err != nil {
+ return repo.getUnit(x, tp)
+}
+
+func (repo *Repository) getUnit(e Engine, tp UnitType) (*RepoUnit, error) {
+ if err := repo.getUnits(e); err != nil {
return nil, err
}
for _, unit := range repo.Units {