-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Only migrate mirrors containing commits in migration v276
#27132
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
Changes from all commits
c900e8b
3b0d26a
8ab220e
53dc5b6
5463e8c
e61de06
b0285ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"path/filepath" | ||
"strings" | ||
|
||
repo_model "code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/git" | ||
giturl "code.gitea.io/gitea/modules/git/url" | ||
"code.gitea.io/gitea/modules/setting" | ||
|
@@ -63,6 +64,8 @@ func migratePullMirrors(x *xorm.Engine) error { | |
var mirrors []Mirror | ||
if err := sess.Select("mirror.id, mirror.repo_id, mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | ||
Join("INNER", "repository", "repository.id = mirror.repo_id"). | ||
Where("repository.status = ?", repo_model.RepositoryReady). | ||
And("repository.is_empty = ?", false). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. If you migrate an empty repository, you still have a pull mirror in the database. This would not update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my above comment, I think they should be updated when the first mirroring. |
||
Limit(limit, start).Find(&mirrors); err != nil { | ||
return err | ||
} | ||
|
@@ -126,6 +129,8 @@ func migratePushMirrors(x *xorm.Engine) error { | |
var mirrors []PushMirror | ||
if err := sess.Select("push_mirror.id, push_mirror.repo_id, push_mirror.remote_name, push_mirror.remote_address, repository.owner_name as repo_owner, repository.name as repo_name"). | ||
Join("INNER", "repository", "repository.id = push_mirror.repo_id"). | ||
Where("repository.status = ?", repo_model.RepositoryReady). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repositories with |
||
And("repository.is_empty = ?", false). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. An empty repository can contain push mirrors. This would not update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An empty repository should have no any git data. So this will avoid read git data here failure. Maybe we can update the remote_address when the first mirror successfully? |
||
Limit(limit, start).Find(&mirrors); err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repositories with
status = RepositoryPendingTransfer
could have mirrors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for migrations, it may/may not have the mirrors. So we cannot assume it always have when the status = RepositoryPendingTransfer. We can only assume when status = RepositoryPendingReady, the git data have the remote.