-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
issue/not-a-bugThe reported issue is the intended behavior or the problem is not inside GiteaThe reported issue is the intended behavior or the problem is not inside Giteamodifies/apiThis PR adds API routes or modifies themThis PR adds API routes or modifies them
Description
- Gitea version (or commit ref):
- Gitea Version: 1.13.0+rc2
- Git version:
- 2.26.2
- Database (use
[x]
):- PostgreSQLMySQLMSSQLSQLiteTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
- OS: Linux / Docker Container.
I have created a repository within an organisation and afterwards I've tried to change the settings of that repository.
This change is being done via REST API. In particular I'm trying to change the entries:
- Can you reproduce the bug at https://try.gitea.io:
- Yes (provide example URL)NoTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Example from within IDEA IntelliJ:
PATCH https://try.gitea.io/api/v1/repos/khmtestorga/testrepo
Authorization: Basic khmarbaise PASSWORD
accept: application/json
Content-Type: application/json
{
"allow_merge_commits": false,
"allow_rebase": false,
"allow_rebase_explicit": false,
"allow_squash_merge": false,
"archived": false,
"default_branch": "master"
}
The answer I got from the request:
PATCH https://try.gitea.io/api/v1/repos/khmtestorga/testrepo
HTTP/1.1 200 OK
Content-Length: 1294
Content-Type: application/json; charset=UTF-8
Date: Wed, 18 Nov 2020 15:59:33 GMT
Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
Set-Cookie: i_like_gitea=d98defc8aa9674ca; Path=/; HttpOnly
Set-Cookie: _csrf=vSQjaJTg6nzcl5Lqkh4bLjFaoJI6MTYwNTcxNTE3Mjg2NTg1NDgyNg; Path=/; Expires=Thu, 19 Nov 2020 15:59:32 GMT; HttpOnly
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
{
"id": 21480,
"owner": {
"id": 42394,
"login": "khmtestorga",
"full_name": "",
"email": "",
"avatar_url": "https://try.gitea.io/user/avatar/khmtestorga/-1",
"language": "",
"is_admin": false,
"last_login": "1970-01-01T00:00:00Z",
"created": "2020-11-18T15:57:08Z",
"username": "khmtestorga"
},
"name": "testrepo",
"full_name": "khmtestorga/testrepo",
"description": "",
"empty": true,
"private": false,
"fork": false,
"template": false,
"parent": null,
"mirror": false,
"size": 17,
"html_url": "https://try.gitea.io/khmtestorga/testrepo",
"ssh_url": "git@try.gitea.io:khmtestorga/testrepo.git",
"clone_url": "https://try.gitea.io/khmtestorga/testrepo.git",
"original_url": "",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 0,
"open_pr_counter": 0,
"release_counter": 0,
"default_branch": "master",
"archived": false,
"created_at": "2020-11-18T15:57:37Z",
"updated_at": "2020-11-18T15:59:33Z",
"permissions": {
"admin": true,
"push": true,
"pull": true
},
"has_issues": true,
"internal_tracker": {
"enable_time_tracker": true,
"allow_only_contributors_to_track_time": true,
"enable_issue_dependencies": true
},
"has_wiki": true,
"has_pull_requests": true,
"has_projects": true,
"ignore_whitespace_conflicts": false,
"allow_merge_commits": true,
"allow_rebase": true,
"allow_rebase_explicit": true,
"allow_squash_merge": true,
"avatar_url": "",
"internal": false
}
Response code: 200 (OK); Time: 967ms; Content length: 1294 bytes
So as you can see that the entries: allow_merge_commits
, allow_rebase
, allow_rebase_explicit
and allow_squash_merge
have not been changed at all.
Desription
The question is if I'm doing the change at the correct API endpoint or do I need to use a different one...
Metadata
Metadata
Assignees
Labels
issue/not-a-bugThe reported issue is the intended behavior or the problem is not inside GiteaThe reported issue is the intended behavior or the problem is not inside Giteamodifies/apiThis PR adds API routes or modifies themThis PR adds API routes or modifies them
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
jolheiser commentedon Nov 18, 2020
The issue here is the API is a little misleading.
On the Swagger page it states
Edit a repository's properties. Only fields that are set will be changed.
However, when you view the model, all the PR-related changes have a small disclaimer
has_pull_requests must be true
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
I think this could be refactored to be easier to work with.
I'm going to close this issue and open a new one detailing the problem.
khmarbaise commentedon Nov 18, 2020
Thanks for your reply and the solution with the details. I've checked that on try.gitea.io and simply it works. Great.