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/repo
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
..
archiver.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
attachment.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
attachment_test.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
avatar.go Add context cache as a request level cache (#22294) 2 years ago
collaboration.go More `db.DefaultContext` refactor (#27265) (#27347) 1 year ago
collaboration_test.go More `db.DefaultContext` refactor (#27265) (#27347) 1 year ago
fork.go Reduce usage of `db.DefaultContext` (#27073) 1 year ago
fork_test.go refactor some functions to support ctx as first parameter (#21878) 2 years ago
git.go Reduce usage of `db.DefaultContext` (#27073) 1 year ago
issue.go Rename almost all Ctx functions (#22071) 2 years ago
language_stats.go Round language stats percentage using largest remainder (#22026) 2 years ago
main_test.go move repository deletion to service layer (#26948) 1 year ago
mirror.go More `db.DefaultContext` refactor (#27265) (#27347) 1 year ago
pushmirror.go Add `RemoteAddress` to mirrors (#26952) 1 year ago
pushmirror_test.go Replace `interface{}` with `any` (#25686) 2 years ago
redirect.go Implement FSFE REUSE for golang files (#21840) 2 years ago
redirect_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
release.go Fix comment permissions (#28213) (#28216) 1 year ago
release_test.go Another round of `db.DefaultContext` refactor (#27103) (#27262) 1 year ago
repo.go Also sync DB branches on push if necessary (#28361) (#28403) 1 year ago
repo_indexer.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_list.go Restricted users only see repos in orgs which their team was assigned to (#28025) (#28051) 1 year ago
repo_list_test.go Replace 'userxx' with 'orgxx' in all test files when the user type is org (#27052) 1 year ago
repo_test.go Replace 'userxx' with 'orgxx' in all test files when the user type is org (#27052) 1 year ago
repo_unit.go Replace `util.SliceXxx` with `slices.Xxx` (#26958) 1 year ago
repo_unit_test.go add disable workflow feature (#26413) 2 years ago
search.go Split "modules/context.go" to separate files (#24569) 2 years ago
star.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
star_test.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
topic.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
topic_test.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
update.go Next round of `db.DefaultContext` refactor (#27089) 1 year ago
upload.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
user_repo.go Refactor authors dropdown (send get request from frontend to avoid long wait time) (#23890) 2 years ago
user_repo_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
watch.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
watch_test.go More refactoring of `db.DefaultContext` (#27083) 1 year ago
wiki.go Implement FSFE REUSE for golang files (#21840) 2 years ago
wiki_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago