Skip to content
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

Fixes #5960 - Adds API Endpoint for Repo Edit #7006

Merged

Conversation

richmahn
Copy link
Contributor

@richmahn richmahn commented May 20, 2019

Fix for #5960

This is to make it so Gitea has the repo Edit API endpoint just like Github. See https://developer.github.com/v3/repos/#edit for what this was to mimic

For the JSON body object, this uses the same names as Github in the JSON binding (one exception: used "webpage" instead of "homepage" since that is what we say in the repo settings page), but uses Gitea property names of the Repository object.

This should be usable for user who has admin privileges to a repo.

All options in the payload for this endpoint are optional, including name (Github says it is required but even for their API it is not and doesn't make sense to be unless your changing the repo name).

@lunny lunny added modifies/api This PR adds API routes or modifies them type/changelog Adds the changelog for a new Gitea version labels May 21, 2019
@lunny lunny added this to the 1.9.0 milestone May 21, 2019
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 21, 2019
@codecov-io
Copy link

codecov-io commented May 22, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@cdd10f1). Click here to learn what that means.
The diff coverage is 74.58%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #7006   +/-   ##
========================================
  Coverage          ?   41.6%           
========================================
  Files             ?     443           
  Lines             ?   60137           
  Branches          ?       0           
========================================
  Hits              ?   25021           
  Misses            ?   31842           
  Partials          ?    3274
Impacted Files Coverage Δ
models/unit.go 67.56% <ø> (ø)
routers/api/v1/api.go 71.22% <100%> (ø)
models/org.go 69.77% <100%> (ø)
routers/api/v1/repo/repo.go 61.05% <70%> (ø)
models/repo.go 49.55% <88.4%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdd10f1...3f44c1c. Read the comment docs.

@richmahn
Copy link
Contributor Author

Made a change to some of the body fields of the JSON for the PATCH endpoint (enable_wiki, enable_issues are has_wiki and has_issues like Github as well as like the repo response object), as well as added these editable fields to the Repository response object so the API can know what was originally set and what is set now.

@zeripath
Copy link
Contributor

Something you've added has caused a deadlock in TestAPIRepoMigrate /go/src/code.gitea.io/gitea/integrations/api_repo_test.go:299

The relevant bit of the stack trace appears to be here:

code.gitea.io/gitea/models.getUnitsByRepoID(0x1bd77a0, 0xc000737ee0, 0x2c, 0x417a78, 0x3, 0x17b84e0, 0x1677401, 0xc0044aff98)
/go/src/code.gitea.io/gitea/models/repo_unit.go:173 +0x103
code.gitea.io/gitea/models.(*Repository).getUnits(...)
/go/src/code.gitea.io/gitea/models/repo.go:333
code.gitea.io/gitea/models.(*Repository).getUnit(0xc0058a5500, 0x1bd77a0, 0xc000737ee0, 0x2, 0xc003e187b0, 0x0, 0x0)
/go/src/code.gitea.io/gitea/models/repo.go:426 +0xf3
code.gitea.io/gitea/models.(*Repository).GetUnit(...)
/go/src/code.gitea.io/gitea/models/repo.go:422
code.gitea.io/gitea/models.(*Repository).innerAPIFormat(0xc0058a5500, 0x1bd7840, 0xc003dec580, 0x4, 0x0, 0x0)
/go/src/code.gitea.io/gitea/models/repo.go:269 +0xf8
code.gitea.io/gitea/models.createRepository(0xc003dec580, 0xc003341b00, 0xc001c346c0, 0xc0058a5500, 0xa3ec93, 0xc000724300)
/go/src/code.gitea.io/gitea/models/repo.go:1319 +0xca8
code.gitea.io/gitea/models.CreateRepository(0xc003341b00, 0xc001c346c0, 0xc00562a080, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/code.gitea.io/gitea/models/repo.go:1372 +0x256
code.gitea.io/gitea/models.MigrateRepository(0xc003341b00, 0xc001c346c0, 0xc00562a080, 0x7, 0x0, 0x0, 0x0, 0xc00610f1c0, 0x23, 0x1, ...)
/go/src/code.gitea.io/gitea/models/repo.go:872 +0x109
code.gitea.io/gitea/modules/migrations.(*GiteaLocalUploader).CreateRepo(0xc003c9de00, 0xc003d52f50, 0x1, 0x0, 0x0)
/go/src/code.gitea.io/gitea/modules/migrations/gitea.go:63 +0x167
code.gitea.io/gitea/modules/migrations.migrateRepository(0x1bc5860, 0xc003d51da0, 0x1bc9e80, 0xc003c9de00, 0xc00610f1c0, 0x23, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/code.gitea.io/gitea/modules/migrations/migrate.go:83 +0x109
code.gitea.io/gitea/modules/migrations.MigrateRepository(0xc003341b00, 0xc00562ab40, 0x5, 0xc00610f1c0, 0x23, 0x0, 0x0, 0x0, 0x0, 0xc00562a080, ...)
/go/src/code.gitea.io/gitea/modules/migrations/migrate.go:59 +0x20c
code.gitea.io/gitea/routers/api/v1/repo.Migrate(0xc003279320, 0xc00399d6e0, 0x23, 0x0, 0x0, 0x0, 0x0, 0x3, 0xc00562a080, 0x7, ...)

models/repo.go Outdated Show resolved Hide resolved
models/repo_unit.go Outdated Show resolved Hide resolved
modules/structs/repo.go Show resolved Hide resolved
routers/api/v1/repo/repo.go Outdated Show resolved Hide resolved
@zeripath zeripath requested review from lunny and lafriks May 26, 2019 22:52
modules/structs/repo.go Outdated Show resolved Hide resolved
@zeripath zeripath requested a review from lunny May 30, 2019 13:01
@techknowlogick techknowlogick merged commit 1831b3b into go-gitea:master May 30, 2019
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this pull request Jul 18, 2019
* Feature - go-gitea#5960 - API Endpoint for Repo Editing

* Revert from merge

* Adds integration testing

* Updates to integration tests

* Revert changes

* Update year in file header

* Misspell fix

* XORM = test

* XORM = test

* revert XORM = file

* Makes RepoUnit.ID be pk and autoincr

* Fix to units

* revert header

* Remove print statement

* Adds other responses

* Improves swagger for creating repo

* Fixes import order

* Better Unit Type does not exist error

* Adds editable repo properties to the response repo structure

* Fix to api_repo_edit_test.go

* Fixes repo test

* Changes per review

* Fixes typo and standardizes comments in the EditRepoOption struct for swagger

* Fixes typo and standardizes comments in the EditRepoOption struct for swagger

* Actually can unarchive through the API

* Unlike delete, user doesn't have to be the owner of the org, just admin to the repo

* Fix to swagger comments for field name change

* Update to swagger docs

* Update swagger

* Changes allow_pull_requests to has_pull_requests
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants