-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Refactor repo.isBare to repo.isEmpty #5629 #5714
Refactor repo.isBare to repo.isEmpty #5629 #5714
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5714 +/- ##
==========================================
- Coverage 37.76% 37.73% -0.03%
==========================================
Files 326 327 +1
Lines 47779 47803 +24
==========================================
- Hits 18043 18038 -5
- Misses 27146 27170 +24
- Partials 2590 2595 +5
Continue to review full report at Codecov.
|
61a5ab6
to
b255a04
Compare
models/migrations/v78.go
Outdated
return err | ||
} | ||
|
||
_, err := sess.Query("UPDATE `repository` SET `is_empty` = `is_bare`") |
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.
Just putting a note here in case we have problems in the future, I've tested this statement sucessfuly on SQLite, and MySQL, we probably won't run into problems with this raw SQL on Postgres, and hopefully we won't run into it on MSSQL (can't test that DB right now sadly).
If errors do arise from this statement, then we'll have to select rows in batches and loop while doing updates on each using XORM Update
function.
models/migrations/v78.go
Outdated
IsEmpty bool `xorm:"INDEX"` | ||
} | ||
|
||
if err := x.Sync(new(Repository)); err != nil { |
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.
Why not just rename column instead of adding/removing?
ALTER TABLE "repository" RENAME COLUMN "is_bare" TO "is_empty";
for MSSQL you have to use:
EXEC sp_rename 'repository.is_bare', 'is_empty', 'COLUMN'
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.
is the line
strings.Contains(err.Error(), "no such column")
still correct?
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.
hard to tell, need to verify that. Also x.Sync is not needed any more otherwise it will add column and rename will fail
Signed-off-by: Andrew Thornton <art27@cantab.net>
7e379a0
to
c4884ae
Compare
Gitea's models/repo.go Repository.IsBare means that a repository is empty rather than that the repository is actually a bare repository in git terms. This is confusing and this PR changes Gitea so that all references to bare only refer to git bare.
Fix #5629
Signed-off-by: Andrew Thornton art27@cantab.net