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

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 this to the 1.9.0 milestone May 21, 2019

Show resolved Hide resolved routers/api/v1/repo/repo.go Outdated

richmahn added some commits May 21, 2019

@codecov-io

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor Author

commented May 25, 2019

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.

richmahn and others added some commits May 25, 2019

@zeripath

This comment has been minimized.

Copy link
Contributor

commented May 26, 2019

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, ...)
Show resolved Hide resolved 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

@zeripath zeripath requested review from lunny and lafriks May 26, 2019

Show resolved Hide resolved modules/structs/repo.go Outdated

@zeripath zeripath requested a review from lunny May 30, 2019

@lunny

lunny approved these changes May 30, 2019

@techknowlogick techknowlogick merged commit 1831b3b into go-gitea:master May 30, 2019

2 checks passed

approvals/lgtm this commit looks good
continuous-integration/drone/pr Build is passing
Details

jeffliu27 added a commit to jeffliu27/gitea that referenced this pull request Jul 18, 2019

Fixes go-gitea#5960 - Adds API Endpoint for Repo Edit (go-gitea#7006)
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants
You can’t perform that action at this time.