1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-23 01:48:27 +00:00

Add has_code to repository REST API (#35214)

similar to how we can enable/disable repos or issues on a repo add the
code unit as option to it.

affects

```
PATCH /repos/{owner}/{repo}
```

---
*Sponsored by Kithara Software GmbH*
This commit is contained in:
6543
2025-08-08 18:18:30 +02:00
committed by GitHub
parent 793815adf7
commit ef613ee760
4 changed files with 78 additions and 0 deletions

View File

@@ -869,6 +869,18 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
}
}
if opts.HasCode != nil && !unit_model.TypeCode.UnitGlobalDisabled() {
if *opts.HasCode {
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
Type: unit_model.TypeCode,
Config: &repo_model.UnitConfig{},
})
} else {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
}
}
if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() {
if *opts.HasPullRequests {
// We do allow setting individual PR settings through the API, so