mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-29 23:34:00 +00:00
Merge 45a4e69ca2
into 54fe47fbca
This commit is contained in:
commit
e50dbdc43e
@ -772,13 +772,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
var units []repo_model.RepoUnit
|
var units []repo_model.RepoUnit
|
||||||
var deleteUnitTypes []unit_model.Type
|
var deleteUnitTypes []unit_model.Type
|
||||||
|
|
||||||
currHasIssues := repo.UnitEnabled(ctx, unit_model.TypeIssues)
|
|
||||||
newHasIssues := currHasIssues
|
|
||||||
if opts.HasIssues != nil {
|
if opts.HasIssues != nil {
|
||||||
newHasIssues = *opts.HasIssues
|
if *opts.HasIssues && opts.ExternalTracker != nil && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
|
||||||
}
|
|
||||||
if currHasIssues || newHasIssues {
|
|
||||||
if newHasIssues && opts.ExternalTracker != nil && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
|
|
||||||
// Check that values are valid
|
// Check that values are valid
|
||||||
if !validation.IsValidExternalURL(opts.ExternalTracker.ExternalTrackerURL) {
|
if !validation.IsValidExternalURL(opts.ExternalTracker.ExternalTrackerURL) {
|
||||||
err := errors.New("External tracker URL not valid")
|
err := errors.New("External tracker URL not valid")
|
||||||
@ -802,7 +797,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues)
|
||||||
} else if newHasIssues && opts.ExternalTracker == nil && !unit_model.TypeIssues.UnitGlobalDisabled() {
|
} else if *opts.HasIssues && opts.ExternalTracker == nil && !unit_model.TypeIssues.UnitGlobalDisabled() {
|
||||||
// Default to built-in tracker
|
// Default to built-in tracker
|
||||||
var config *repo_model.IssuesConfig
|
var config *repo_model.IssuesConfig
|
||||||
|
|
||||||
@ -829,7 +824,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
|
||||||
} else if !newHasIssues {
|
} else if !*opts.HasIssues {
|
||||||
if !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
|
if !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
|
||||||
}
|
}
|
||||||
@ -839,13 +834,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currHasWiki := repo.UnitEnabled(ctx, unit_model.TypeWiki)
|
|
||||||
newHasWiki := currHasWiki
|
|
||||||
if opts.HasWiki != nil {
|
if opts.HasWiki != nil {
|
||||||
newHasWiki = *opts.HasWiki
|
if *opts.HasWiki && opts.ExternalWiki != nil && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
|
||||||
}
|
|
||||||
if currHasWiki || newHasWiki {
|
|
||||||
if newHasWiki && opts.ExternalWiki != nil && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
|
|
||||||
// Check that values are valid
|
// Check that values are valid
|
||||||
if !validation.IsValidExternalURL(opts.ExternalWiki.ExternalWikiURL) {
|
if !validation.IsValidExternalURL(opts.ExternalWiki.ExternalWikiURL) {
|
||||||
err := errors.New("External wiki URL not valid")
|
err := errors.New("External wiki URL not valid")
|
||||||
@ -861,7 +851,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeWiki)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeWiki)
|
||||||
} else if newHasWiki && opts.ExternalWiki == nil && !unit_model.TypeWiki.UnitGlobalDisabled() {
|
} else if *opts.HasWiki && opts.ExternalWiki == nil && !unit_model.TypeWiki.UnitGlobalDisabled() {
|
||||||
config := &repo_model.UnitConfig{}
|
config := &repo_model.UnitConfig{}
|
||||||
units = append(units, repo_model.RepoUnit{
|
units = append(units, repo_model.RepoUnit{
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
@ -869,7 +859,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
|
||||||
} else if !newHasWiki {
|
} else if !*opts.HasWiki {
|
||||||
if !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
|
if !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
|
||||||
}
|
}
|
||||||
@ -879,13 +869,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currHasPullRequests := repo.UnitEnabled(ctx, unit_model.TypePullRequests)
|
if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
||||||
newHasPullRequests := currHasPullRequests
|
if *opts.HasPullRequests {
|
||||||
if opts.HasPullRequests != nil {
|
|
||||||
newHasPullRequests = *opts.HasPullRequests
|
|
||||||
}
|
|
||||||
if currHasPullRequests || newHasPullRequests {
|
|
||||||
if newHasPullRequests && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
|
||||||
// We do allow setting individual PR settings through the API, so
|
// We do allow setting individual PR settings through the API, so
|
||||||
// we get the config settings and then set them
|
// we get the config settings and then set them
|
||||||
// if those settings were provided in the opts.
|
// if those settings were provided in the opts.
|
||||||
@ -953,18 +938,13 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Type: unit_model.TypePullRequests,
|
Type: unit_model.TypePullRequests,
|
||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
} else if !newHasPullRequests && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
} else {
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePullRequests)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePullRequests)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currHasProjects := repo.UnitEnabled(ctx, unit_model.TypeProjects)
|
if opts.HasProjects != nil && !unit_model.TypeProjects.UnitGlobalDisabled() {
|
||||||
newHasProjects := currHasProjects
|
if *opts.HasProjects {
|
||||||
if opts.HasProjects != nil {
|
|
||||||
newHasProjects = *opts.HasProjects
|
|
||||||
}
|
|
||||||
if currHasProjects || newHasProjects {
|
|
||||||
if newHasProjects && !unit_model.TypeProjects.UnitGlobalDisabled() {
|
|
||||||
unit, err := repo.GetUnit(ctx, unit_model.TypeProjects)
|
unit, err := repo.GetUnit(ctx, unit_model.TypeProjects)
|
||||||
var config *repo_model.ProjectsConfig
|
var config *repo_model.ProjectsConfig
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -984,7 +964,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Type: unit_model.TypeProjects,
|
Type: unit_model.TypeProjects,
|
||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
} else if !newHasProjects && !unit_model.TypeProjects.UnitGlobalDisabled() {
|
} else {
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
|
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,8 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
|
|||||||
hasWiki = true
|
hasWiki = true
|
||||||
} else if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeExternalWiki); err == nil {
|
} else if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeExternalWiki); err == nil {
|
||||||
hasWiki = true
|
hasWiki = true
|
||||||
config := unit.ExternalWikiConfig()
|
|
||||||
externalWiki = &api.ExternalWiki{
|
externalWiki = &api.ExternalWiki{
|
||||||
ExternalWikiURL: config.ExternalWikiURL,
|
ExternalWikiURL: unit.ExternalWikiConfig().ExternalWikiURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defaultBranch := repo.DefaultBranch
|
defaultBranch := repo.DefaultBranch
|
||||||
|
Loading…
Reference in New Issue
Block a user