You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/models
Lunny Xiao 87db4a47c8
Also sync DB branches on push if necessary (#28361) (#28403)
Fix #28056
Backport #28361 

This PR will check whether the repo has zero branch when pushing a
branch. If that, it means this repository hasn't been synced.

The reason caused that is after user upgrade from v1.20 -> v1.21, he
just push branches without visit the repository user interface. Because
all repositories routers will check whether a branches sync is necessary
but push has not such check.

For every repository, it has two states, synced or not synced. If there
is zero branch for a repository, then it will be assumed as non-sync
state. Otherwise, it's synced state. So if we think it's synced, we just
need to update branch/insert new branch. Otherwise do a full sync. So
that, for every push, there will be almost no extra load added. It's
high performance than yours.

For the implementation, we in fact will try to update the branch first,
if updated success with affect records > 0, then all are done. Because
that means the branch has been in the database. If no record is
affected, that means the branch does not exist in database. So there are
two possibilities. One is this is a new branch, then we just need to
insert the record. Another is the branches haven't been synced, then we
need to sync all the branches into database.
1 year ago
..
actions Fix no ActionTaskOutput table waring (#28149) (#28152) 1 year ago
activities Add Index to `action.user_id` (#27403) (#27425) 1 year ago
admin Next round of `db.DefaultContext` refactor (#27089) 2 years ago
asymkey Fix comment permissions (#28213) (#28216) 1 year ago
auth Fix wrong xorm Delete usage(backport for 1.21) (#28002) 1 year ago
avatars Refactor system setting (#27000) (#27452) 1 year ago
db Also sync DB branches on push if necessary (#28361) (#28403) 1 year ago
dbfs Fix content holes in Actions task logs file (#25560) 2 years ago
fixtures Fix comment permissions (#28213) (#28216) 1 year ago
git Also sync DB branches on push if necessary (#28361) (#28403) 1 year ago
issues Fix comment permissions (#28213) (#28216) 1 year ago
migrations handle repository.size column being NULL in migration v263 (#28336) (#28363) 1 year ago
organization Another round of `db.DefaultContext` refactor (#27103) (#27262) 1 year ago
packages move repository deletion to service layer (#26948) 2 years ago
perm move repository deletion to service layer (#26948) 2 years ago
project Fix comment permissions (#28213) (#28216) 1 year ago
pull refactor some functions to support ctx as first parameter (#21878) 2 years ago
repo Also sync DB branches on push if necessary (#28361) (#28403) 1 year ago
secret Refactor secrets modification logic (#26873) 2 years ago
shared/types Display owner of a runner as a tooltip instead of static text (#24377) 2 years ago
system Increase "version" when update the setting value to a same value as before (#28243) (#28244) 1 year ago
unit Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804) 2 years ago
unittest Upgrade xorm (#27673) (#27691) 1 year ago
user enable system users search via the API (#28013) (#28018) 1 year ago
webhook Fix comment permissions (#28213) (#28216) 1 year ago
error.go Sync branches into databases (#22743) 2 years ago
fixture_generation.go Fix yaml test (#27297) (#27303) 1 year ago
fixture_test.go Fix yaml test (#27297) (#27303) 1 year ago
main_test.go move repository deletion to service layer (#26948) 2 years ago
org.go refactor some functions to support ctx as first parameter (#21878) 2 years ago
org_team.go Use db.WithTx for AddTeamMember to avoid ctx abuse (#27095) 2 years ago
org_team_test.go Reduce usage of `db.DefaultContext` (#27073) 2 years ago
org_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo.go Refactor system setting (#27000) (#27452) 1 year ago
repo_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_transfer.go Next round of `db.DefaultContext` refactor (#27089) 2 years ago
repo_transfer_test.go Next round of `db.DefaultContext` refactor (#27089) 2 years ago