-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
api does not change repository properties #15121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can only partially reproduce: Changing most of these flags works, edit: thanks for the nice reproducer! |
That's strange. On my production system I'm running 1.13.5, too, and it behaves the same as the version on try.gitea.io: It does not change anything. It doesn't even matter how many options I try to change at once. curl -s -X PATCH \
-H "Accept: application/json" -H "Authorization: token ${token}" \
"${apiurl}/repos/rpms/ccache" \
-d '{"private":true,"has_issues":false,"has_pull_requests":false,"has_projects":false,"has_wiki":false}' | \
jq '.|{has_wiki,has_issues,has_pull_requests,has_projects,private}' {
"has_wiki": true,
"has_issues": true,
"has_pull_requests": true,
"has_projects": true,
"private": false
}
which translates to Execute UPDATE `repository` SET `owner_id` = 3, `owner_name` = 'rpms', `lower_name` = 'ccache',
`name` = 'ccache', `description` = 'rpm package source of ccache', `website` = '',
`original_service_type` = 0, `original_url` = '', `default_branch` = 'master', `num_watches` = 1,
`num_stars` = 0, `num_forks` = 0, `num_issues` = 0, `num_closed_issues` = 0, `num_pulls` = 0,
`num_closed_pulls` = 0, `num_milestones` = 0, `num_closed_milestones` = 0, `num_projects` = 0,
`num_closed_projects` = 0, `is_private` = 0, `is_empty` = 0, `is_archived` = 0, `is_mirror` = 0,
`status` = 0, `is_fork` = 0, `fork_id` = 0, `is_template` = 0, `template_id` = 0, `size` = 19558,
`is_fsck_enabled` = 1, `close_issues_via_commit_in_any_branch` = 0, `topics` = 'null',
`trust_model` = 0, `avatar` = '', `updated_unix` = 1616574014 WHERE `id`=14
mysql(root@localhost) [gitea]> select * from repository where name = "ccache"\G
*************************** 1. row ***************************
id: 14
owner_id: 3
lower_name: ccache
name: ccache
description: rpm package source of ccache
website:
default_branch: master
num_watches: 1
num_stars: 0
num_forks: 0
num_issues: 0
num_closed_issues: 0
num_pulls: 0
num_closed_pulls: 0
num_milestones: 0
num_closed_milestones: 0
is_private: 0
is_mirror: 0
enable_wiki: 1
enable_external_wiki: 0
external_wiki_url:
enable_issues: 0
enable_external_tracker: 0
external_tracker_url:
external_tracker_format:
external_tracker_style:
enable_pulls: 0
is_fork: 0
fork_id: 0
created_unix: 1488205778
updated_unix: 1616573388
size: 19558
is_fsck_enabled: 1
topics: null
is_empty: 0
close_issues_via_commit_in_any_branch: 0
is_archived: 0
avatar:
original_url:
status: 0
original_service_type: 0
is_template: 0
template_id: 0
owner_name: rpms
num_projects: 0
num_closed_projects: 0
trust_model: 0
1 row in set (0.001 sec) I found out that as I started quite early with gitea and did lots of version upgrades since then, my database schema seems to be fscked up as gitea seemingly no longer uses Offtopic: is it safe to remove the no longer used columns from the tables? But alas, even the freshly installed gitea does not change anything using the api, probably because of the Take a look at the different queries when changing the repository's settings:
|
I'm sorry, but I hasn't found any bug by test code,I wonder ..... test code func TestAPIEditRepo(t *testing.T) {
defer prepareTestEnv(t)()
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
repo1 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
session := loginUser(t, user.Name)
token := getTokenForLoggedInUser(t, session)
// test edit base repo config
newDesc := "test new description"
newWeb := "http://example.com"
req := NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", repo1.OwnerName, repo1.Name, token), &api.EditRepoOption{
Description: &newDesc,
Website: &newWeb,
})
session.MakeRequest(t, req, http.StatusOK)
repo1 = models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
assert.Equal(t, newDesc, repo1.Description)
assert.Equal(t, newWeb, repo1.Website)
optFalse := false
optTrue := true
// test edit repo units config
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s?token=%s", repo1.OwnerName, repo1.Name, token), &api.EditRepoOption{
HasIssues: &optFalse,
HasPullRequests: &optFalse,
Private: &optTrue,
})
session.MakeRequest(t, req, http.StatusOK)
var repo api.Repository
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1?token="+ token)
resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &repo)
assert.Equal(t, false, repo.HasIssues)
assert.Equal(t, false, repo.HasPullRequests)
assert.Equal(t, true, repo.Private)
} |
So you cannot reproduce it? That's strange. I am able to reproduce it in my production environment, on a freshly installed test vm, on try.gitea.io and even on a docker container As I'm not a native go speaker: do your queries in that test code differ from mine? You're using |
I found the issue. Instead of |
Darn, you're right. Setting the content-type works fine. Sorry for the noise 😞 |
[x]
):Description
trying to update some repository's attributes like disabling the issue tracker, pull requests, the wiki, converting it to private, doesn't have any effect.
Screenshots
The text was updated successfully, but these errors were encountered: