-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
modifies/apiThis PR adds API routes or modifies themThis PR adds API routes or modifies them
Description
- Gitea version (or commit ref): latest
- Git version: try
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)
- No
Description
Related #13620
In the repository configuration API, we have pseudo-required parameters which are misleading and can be confusing for users.
My own quote below, the API skips entire sections if you fail to specify that the unit is enabled, regardless of whether it was already enabled or not.
Basically, because you didn't specify
"has_pull_requests": true
the API skipped the PR-related values entirely. 🙃
gitea/routers/api/v1/repo/repo.go
Lines 684 to 728 in 5a991ec
if opts.HasPullRequests != nil { | |
if *opts.HasPullRequests && !models.UnitTypePullRequests.UnitGlobalDisabled() { | |
// We do allow setting individual PR settings through the API, so | |
// we get the config settings and then set them | |
// if those settings were provided in the opts. | |
unit, err := repo.GetUnit(models.UnitTypePullRequests) | |
var config *models.PullRequestsConfig | |
if err != nil { | |
// Unit type doesn't exist so we make a new config file with default values | |
config = &models.PullRequestsConfig{ | |
IgnoreWhitespaceConflicts: false, | |
AllowMerge: true, | |
AllowRebase: true, | |
AllowRebaseMerge: true, | |
AllowSquash: true, | |
} | |
} else { | |
config = unit.PullRequestsConfig() | |
} | |
if opts.IgnoreWhitespaceConflicts != nil { | |
config.IgnoreWhitespaceConflicts = *opts.IgnoreWhitespaceConflicts | |
} | |
if opts.AllowMerge != nil { | |
config.AllowMerge = *opts.AllowMerge | |
} | |
if opts.AllowRebase != nil { | |
config.AllowRebase = *opts.AllowRebase | |
} | |
if opts.AllowRebaseMerge != nil { | |
config.AllowRebaseMerge = *opts.AllowRebaseMerge | |
} | |
if opts.AllowSquash != nil { | |
config.AllowSquash = *opts.AllowSquash | |
} | |
units = append(units, models.RepoUnit{ | |
RepoID: repo.ID, | |
Type: models.UnitTypePullRequests, | |
Config: config, | |
}) | |
} else if !*opts.HasPullRequests && !models.UnitTypePullRequests.UnitGlobalDisabled() { | |
deleteUnitTypes = append(deleteUnitTypes, models.UnitTypePullRequests) | |
} | |
} |
This is somewhat contradictory to the description of the API route itself.
Edit a repository's properties. Only fields that are set will be changed.
6543
Metadata
Metadata
Assignees
Labels
modifies/apiThis PR adds API routes or modifies themThis PR adds API routes or modifies them