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

Adopt repositories #12920

Merged
merged 29 commits into from
Sep 25, 2020
Merged

Adopt repositories #12920

merged 29 commits into from
Sep 25, 2020

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Sep 21, 2020

This PR is a rewrite of #12409 to remove the adopt/overwrite option as per @6543 and @lunny.

Prior to this PR Gitea would delete any repository files if they are
present during creation or migration. This can in certain circumstances
lead to data-loss and is slightly unpleasant.

This PR provides a mechanism for Gitea to adopt repositories or delete unadopted repositories by creating a new page
/admin/repos/unadopted which allow the administrator to search for unadopted repositories.

If normal users are allowed to adopt and/or delete unadopted repositories these will appear on /user/settings/repos

There is an API for the (administrator user only) /api/v1/admin/unadopted to list unadopted and POSTing to /api/v1/admin/unadopted/:username/:reponame will adopt whilst DELETE will delete them.

Closes #12409

Signed-off-by: Andrew Thornton art27@cantab.net

Prior to this PR Gitea would delete any repository files if they are
present during creation or migration. This can in certain circumstances
lead to data-loss and is slightly unpleasant.

This PR provides a mechanism for Gitea to adopt repositories on creation
and otherwise requires an explicit flag for deletion.

PushCreate is slightly different - the create will cause adoption if
that is allowed otherwise it will delete the data if that is allowed.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Only offer to adopt or overwrite if the user can do that.

Allow the site administrator to adopt or overwrite in all
circumstances

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added the pr/wip This PR is not ready for review label Sep 21, 2020
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/user/setting/adopt.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 21, 2020
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/admin/repos.go Outdated Show resolved Hide resolved
routers/user/setting/adopt.go Outdated Show resolved Hide resolved
Signed-off-by: Andrew Thornton <art27@cantab.net>
@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2020

Codecov Report

Merging #12920 into master will decrease coverage by 0.24%.
The diff coverage is 8.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12920      +/-   ##
==========================================
- Coverage   43.06%   42.82%   -0.25%     
==========================================
  Files         658      661       +3     
  Lines       72477    72974     +497     
==========================================
+ Hits        31214    31252      +38     
- Misses      36200    36653     +453     
- Partials     5063     5069       +6     
Impacted Files Coverage Δ
models/error.go 34.51% <0.00%> (-0.30%) ⬇️
models/repo_list.go 79.46% <ø> (ø)
models/user.go 53.58% <0.00%> (-0.30%) ⬇️
modules/git/repo_branch.go 74.44% <0.00%> (-1.70%) ⬇️
modules/repository/adopt.go 0.00% <0.00%> (ø)
modules/repository/generate.go 0.00% <0.00%> (ø)
routers/admin/repos.go 0.00% <0.00%> (ø)
routers/api/v1/admin/adopt.go 0.00% <0.00%> (ø)
routers/api/v1/repo/migrate.go 42.96% <0.00%> (-0.65%) ⬇️
routers/repo/repo.go 27.59% <0.00%> (-1.14%) ⬇️
... and 27 more

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 6fa19a8...d1a4365. Read the comment docs.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath changed the title [WIP] Adopt repositories 2 Adopt repositories 2 Sep 23, 2020
@zeripath zeripath removed the pr/wip This PR is not ready for review label Sep 23, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@6543
Copy link
Member

6543 commented Sep 23, 2020

@zeripath one thing: the addoption task has to ensure to not set a not existing default branch

Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 23, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Sep 24, 2020
@zeripath zeripath added this to the 1.13.0 milestone Sep 24, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
Copy link
Member

@lafriks lafriks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit about unneeded commented out code but otherwise lg-tm

modules/repository/create.go Outdated Show resolved Hide resolved
Signed-off-by: Andrew Thornton <art27@cantab.net>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 24, 2020
@lafriks lafriks merged commit 7a7f560 into go-gitea:master Sep 25, 2020
@lafriks lafriks changed the title Adopt repositories 2 Adopt repositories Sep 25, 2020
@lunny lunny added the type/changelog Adds the changelog for a new Gitea version label Sep 25, 2020
@zeripath zeripath deleted the adopt-repositories-2 branch September 25, 2020 17:00
@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. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants