mirror of
https://github.com/go-gitea/gitea
synced 2024-07-07 10:35:48 +00:00
Rewrite existing repo units if setting is not included in api body (#7811)
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
This commit is contained in:
parent
9b95b41aa8
commit
0fa9ea516a
@ -646,8 +646,14 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.HasIssues != nil {
|
if opts.HasIssues == nil {
|
||||||
if *opts.HasIssues {
|
// If HasIssues setting not touched, rewrite existing repo unit
|
||||||
|
if unit, err := repo.GetUnit(models.UnitTypeIssues); err == nil {
|
||||||
|
units = append(units, *unit)
|
||||||
|
} else if unit, err := repo.GetUnit(models.UnitTypeExternalTracker); err == nil {
|
||||||
|
units = append(units, *unit)
|
||||||
|
}
|
||||||
|
} else if *opts.HasIssues {
|
||||||
// We don't currently allow setting individual issue settings through the API,
|
// We don't currently allow setting individual issue settings through the API,
|
||||||
// only can enable/disable issues, so when enabling issues,
|
// only can enable/disable issues, so when enabling issues,
|
||||||
// we either get the existing config which means it was already enabled,
|
// we either get the existing config which means it was already enabled,
|
||||||
@ -670,10 +676,15 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if opts.HasWiki != nil {
|
if opts.HasWiki == nil {
|
||||||
if *opts.HasWiki {
|
// If HasWiki setting not touched, rewrite existing repo unit
|
||||||
|
if unit, err := repo.GetUnit(models.UnitTypeWiki); err == nil {
|
||||||
|
units = append(units, *unit)
|
||||||
|
} else if unit, err := repo.GetUnit(models.UnitTypeExternalWiki); err == nil {
|
||||||
|
units = append(units, *unit)
|
||||||
|
}
|
||||||
|
} else if *opts.HasWiki {
|
||||||
// We don't currently allow setting individual wiki settings through the API,
|
// We don't currently allow setting individual wiki settings through the API,
|
||||||
// only can enable/disable the wiki, so when enabling the wiki,
|
// only can enable/disable the wiki, so when enabling the wiki,
|
||||||
// we either get the existing config which means it was already enabled,
|
// we either get the existing config which means it was already enabled,
|
||||||
@ -685,10 +696,13 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if opts.HasPullRequests != nil {
|
if opts.HasPullRequests == nil {
|
||||||
if *opts.HasPullRequests {
|
// If HasPullRequest setting not touched, rewrite existing repo unit
|
||||||
|
if unit, err := repo.GetUnit(models.UnitTypePullRequests); err == nil {
|
||||||
|
units = append(units, *unit)
|
||||||
|
}
|
||||||
|
} else if *opts.HasPullRequests {
|
||||||
// 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.
|
||||||
@ -729,7 +743,6 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||||||
Config: config,
|
Config: config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := models.UpdateRepositoryUnits(repo, units); err != nil {
|
if err := models.UpdateRepositoryUnits(repo, units); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err)
|
ctx.Error(http.StatusInternalServerError, "UpdateRepositoryUnits", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user