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

preserve users if restoring a repository on the same Gitea instance #18604

Merged
merged 2 commits into from
Feb 6, 2022

Conversation

singuliere
Copy link
Contributor

When calling DumpRepository and RestoreRepository on the same Gitea
instance, the users are preserved: all labels, issues etc. belong to
the external user who is, in this particular case, the local user.

Dead code verifying g.gitServiceType.Name() == "" (i.e. plain git) is
removed. The function is never called because the plain git downloader
does not migrate anything that is associated to a user, by definition.

Errors returned by GetUserIDByExternalUserID are no longer ignored.

The userMap is used when the external user is not kown, which is the
most common case. It was only used when the external user exists
which happens less often and, as a result, every occurence of an
unknown external user required a SQL query.

Signed-off-by: Loïc Dachary loic@dachary.org


forgefriends source

When calling DumpRepository and RestoreRepository on the same Gitea
instance, the users are preserved: all labels, issues etc. belong to
the external user who is, in this particular case, the local user.

Dead code verifying g.gitServiceType.Name() == "" (i.e. plain git) is
removed. The function is never called because the plain git downloader
does not migrate anything that is associated to a user, by definition.

Errors returned by GetUserIDByExternalUserID are no longer ignored.

The userMap is used when the external user is not kown, which is the
most common case. It was only used when the external user exists
which happens less often and, as a result, every occurence of an
unknown external user required a SQL query.

Signed-off-by: Loïc Dachary <loic@dachary.org>
@singuliere singuliere added type/bug performance/speed performance issues with slow downs labels Feb 4, 2022
@singuliere singuliere added this to the 1.17.0 milestone Feb 4, 2022
@singuliere
Copy link
Contributor Author

singuliere commented Feb 4, 2022

I classified this as kind/bug because there is no way to restore a repository on the same Gitea instance and preserve the users. And performance/speed because it also saves a large number of unecessary SQL requests during the import.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 4, 2022
@singuliere singuliere added the topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them label Feb 4, 2022
@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 Feb 5, 2022
@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 Feb 6, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #18604 (e9d0063) into main (80048c0) will increase coverage by 0.07%.
The diff coverage is 50.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #18604      +/-   ##
==========================================
+ Coverage   46.25%   46.32%   +0.07%     
==========================================
  Files         842      846       +4     
  Lines      121180   121236      +56     
==========================================
+ Hits        56052    56164     +112     
+ Misses      58321    58260      -61     
- Partials     6807     6812       +5     
Impacted Files Coverage Δ
models/commit.go 62.50% <0.00%> (ø)
models/release.go 49.45% <0.00%> (-1.49%) ⬇️
models/review.go 50.29% <0.00%> (-0.60%) ⬇️
models/user/external_login_user.go 28.57% <ø> (ø)
modules/git/notes_nogogit.go 66.66% <0.00%> (-2.19%) ⬇️
modules/gitgraph/graph_models.go 80.85% <0.00%> (ø)
modules/migration/pullrequest.go 0.00% <0.00%> (ø)
modules/migration/release.go 0.00% <0.00%> (ø)
modules/migration/review.go 0.00% <0.00%> (ø)
modules/queue/manager.go 40.41% <0.00%> (-1.22%) ⬇️
... and 37 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 9419dd2...e9d0063. Read the comment docs.

@lunny lunny merged commit 8bd89ca into go-gitea:main Feb 6, 2022
Gusted pushed a commit to Gusted/gitea that referenced this pull request Feb 6, 2022
- Pass the correct context into `db.GetEngine()`.
- Introduced in: go-gitea#18604
@Gusted Gusted mentioned this pull request Feb 6, 2022
zeripath pushed a commit that referenced this pull request Feb 6, 2022
- Pass the correct context into `db.GetEngine()`.
- Introduced in: #18604
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
…o-gitea#18604)

When calling DumpRepository and RestoreRepository on the same Gitea
instance, the users are preserved: all labels, issues etc. belong to
the external user who is, in this particular case, the local user.

Dead code verifying g.gitServiceType.Name() == "" (i.e. plain git) is
removed. The function is never called because the plain git downloader
does not migrate anything that is associated to a user, by definition.

Errors returned by GetUserIDByExternalUserID are no longer ignored.

The userMap is used when the external user is not kown, which is the
most common case. It was only used when the external user exists
which happens less often and, as a result, every occurence of an
unknown external user required a SQL query.

Signed-off-by: Loïc Dachary <loic@dachary.org>

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
- Pass the correct context into `db.GetEngine()`.
- Introduced in: go-gitea#18604
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
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. performance/speed performance issues with slow downs topic/repo-migration Migrate repos from other platforms to Gitea, or from Gitea to them type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants