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

Sync branches into databases #22743

Merged
merged 82 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
df49449
sync branches into databases
lunny Feb 4, 2023
a495e75
add migration
lunny Apr 9, 2023
040b8bd
merge main branch & fix bug
lunny Apr 9, 2023
0a8cbc9
some improvements
lunny Apr 9, 2023
71f62de
merge main branch
lunny Jun 14, 2023
9effdb8
Add new columns
lunny Jun 14, 2023
86b3c75
Merge branch 'main' into lunny/sync_branches
lunny Jun 15, 2023
458052b
rewrite branches page
lunny Jun 15, 2023
01a647d
Merge branch 'main' into lunny/sync_branches
lunny Jun 15, 2023
2c10f0c
Remove deletedbranch table and migrate data to branch
lunny Jun 15, 2023
60d1258
Fix test
lunny Jun 15, 2023
c833ef8
Fix lint
lunny Jun 15, 2023
718676e
Use database branches
lunny Jun 15, 2023
baef989
Fix test
lunny Jun 15, 2023
c065650
Fix import
lunny Jun 15, 2023
935f567
Only create branch when creating a non-empty repository
lunny Jun 16, 2023
3c45a93
Merge branch 'main' into lunny/sync_branches
lunny Jun 16, 2023
9f45325
replace another get branches
lunny Jun 16, 2023
a23a8bf
Fix test
lunny Jun 16, 2023
8b3489d
Fix lint
lunny Jun 16, 2023
166df87
Fix test
lunny Jun 16, 2023
ce889a8
Merge branch 'main' into lunny/sync_branches
lunny Jun 16, 2023
f1ba5ff
Fix test
lunny Jun 16, 2023
1c63742
small optimization
lunny Jun 16, 2023
26ee52d
Fix test data
lunny Jun 17, 2023
e83eff5
Merge branch 'main' into lunny/sync_branches
lunny Jun 17, 2023
7eb222c
Fix tests
lunny Jun 17, 2023
b521271
Fix test
lunny Jun 17, 2023
9b6d942
Fix migration
lunny Jun 18, 2023
4937576
Fix open git repository
lunny Jun 18, 2023
c49d979
Merge branch 'main' into lunny/sync_branches
lunny Jun 18, 2023
086c486
Fix test
lunny Jun 18, 2023
bad2fff
Merge branch 'main' into lunny/sync_branches
lunny Jun 18, 2023
76bd35e
Fix branch deletion
lunny Jun 18, 2023
68da680
sync branches when migrating
lunny Jun 19, 2023
258368d
Merge branch 'main' into lunny/sync_branches
lunny Jun 19, 2023
65de47b
Fix lint
lunny Jun 19, 2023
cd2ac23
Fix sync
lunny Jun 20, 2023
51d20f1
Merge branch 'main' into lunny/sync_branches
lunny Jun 20, 2023
861a5ee
Add fallback and a button for admin to sync
lunny Jun 22, 2023
3ad4756
Merge branch 'main' into lunny/sync_branches
lunny Jun 22, 2023
b282988
Revert unnecessary cron job and fix lint
lunny Jun 22, 2023
a2f6d2e
Merge branch 'main' into lunny/sync_branches
lunny Jun 22, 2023
968e1ec
Add error track
lunny Jun 22, 2023
095e678
Merge branch 'main' into lunny/sync_branches
lunny Jun 22, 2023
efa3301
Prepare data when database is ready
lunny Jun 24, 2023
7e7616e
Merge branch 'main' into lunny/sync_branches
lunny Jun 24, 2023
831075a
Merge branch 'main' into lunny/sync_branches
lunny Jun 24, 2023
adbfecd
fix test
lunny Jun 24, 2023
c1c5ec7
Merge branch 'main' into lunny/sync_branches
lunny Jun 24, 2023
b1c8b39
Fix lint
lunny Jun 24, 2023
6e90189
Fix check
lunny Jun 25, 2023
ef5feb8
Merge branch 'main' into lunny/sync_branches
lunny Jun 25, 2023
2761e08
Add lin ending
lunny Jun 25, 2023
67a83b9
Fix bug
lunny Jun 25, 2023
1fd12aa
Merge branch 'main' into lunny/sync_branches
lunny Jun 25, 2023
8279c91
Follow wxiaoguang's suggestion
lunny Jun 25, 2023
178c965
Follow wxiaoguang's suggestion
lunny Jun 26, 2023
d718ad9
Merge branch 'main' into lunny/sync_branches
lunny Jun 26, 2023
9bc6efb
Fix test
lunny Jun 26, 2023
19d3b4c
Use sync instead of insert data
lunny Jun 26, 2023
aea20e2
Merge branch 'main' into lunny/sync_branches
lunny Jun 26, 2023
ed46267
Follow wolfogre's suggestion
lunny Jun 27, 2023
d229581
Merge branch 'main' into lunny/sync_branches
lunny Jun 27, 2023
c68beb6
directly read git repository branches
lunny Jun 28, 2023
d805572
Merge branch 'main' into lunny/sync_branches
lunny Jun 28, 2023
3fa6914
Display pusher on branches list page
lunny Jun 28, 2023
625de6e
Some improvements
lunny Jun 28, 2023
425929b
Update modules/repository/branch.go
lunny Jun 28, 2023
9c102e8
Don't use admin user as branch pusher
lunny Jun 28, 2023
fd6db0f
Fix bug
lunny Jun 28, 2023
e96621c
Follow wxiaoguang's suggestion
lunny Jun 28, 2023
916e00b
Merge branch 'main' into lunny/sync_branches
lunny Jun 28, 2023
61fa367
Remove unused function
lunny Jun 28, 2023
3cdf0d9
Add some comment for LoadDeletedBy
lunny Jun 28, 2023
2f8fbfe
Add sync for ListBranch and DeleteBranch API
lunny Jun 28, 2023
41359d8
Don't put the failure sync branches task back to queue
lunny Jun 28, 2023
1ab19bd
Fix some bugs
lunny Jun 28, 2023
c41ad16
Delete a deleted branch now return no error
lunny Jun 28, 2023
cd195ab
Use unique queue
lunny Jun 28, 2023
32bc932
Merge branch 'main' into lunny/sync_branches
lunny Jun 29, 2023
98f5557
Merge branch 'main' into lunny/sync_branches
GiteaBot Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions models/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,90 +318,6 @@ func (err ErrFilePathProtected) Unwrap() error {
return util.ErrPermissionDenied
}

// __________ .__
// \______ \____________ ____ ____ | |__
// | | _/\_ __ \__ \ / \_/ ___\| | \
// | | \ | | \// __ \| | \ \___| Y \
// |______ / |__| (____ /___| /\___ >___| /
// \/ \/ \/ \/ \/

// ErrBranchDoesNotExist represents an error that branch with such name does not exist.
type ErrBranchDoesNotExist struct {
BranchName string
}

// IsErrBranchDoesNotExist checks if an error is an ErrBranchDoesNotExist.
func IsErrBranchDoesNotExist(err error) bool {
_, ok := err.(ErrBranchDoesNotExist)
return ok
}

func (err ErrBranchDoesNotExist) Error() string {
return fmt.Sprintf("branch does not exist [name: %s]", err.BranchName)
}

func (err ErrBranchDoesNotExist) Unwrap() error {
return util.ErrNotExist
}

// ErrBranchAlreadyExists represents an error that branch with such name already exists.
type ErrBranchAlreadyExists struct {
BranchName string
}

// IsErrBranchAlreadyExists checks if an error is an ErrBranchAlreadyExists.
func IsErrBranchAlreadyExists(err error) bool {
_, ok := err.(ErrBranchAlreadyExists)
return ok
}

func (err ErrBranchAlreadyExists) Error() string {
return fmt.Sprintf("branch already exists [name: %s]", err.BranchName)
}

func (err ErrBranchAlreadyExists) Unwrap() error {
return util.ErrAlreadyExist
}

// ErrBranchNameConflict represents an error that branch name conflicts with other branch.
type ErrBranchNameConflict struct {
BranchName string
}

// IsErrBranchNameConflict checks if an error is an ErrBranchNameConflict.
func IsErrBranchNameConflict(err error) bool {
_, ok := err.(ErrBranchNameConflict)
return ok
}

func (err ErrBranchNameConflict) Error() string {
return fmt.Sprintf("branch conflicts with existing branch [name: %s]", err.BranchName)
}

func (err ErrBranchNameConflict) Unwrap() error {
return util.ErrAlreadyExist
}

// ErrBranchesEqual represents an error that branch name conflicts with other branch.
type ErrBranchesEqual struct {
BaseBranchName string
HeadBranchName string
}

// IsErrBranchesEqual checks if an error is an ErrBranchesEqual.
func IsErrBranchesEqual(err error) bool {
_, ok := err.(ErrBranchesEqual)
return ok
}

func (err ErrBranchesEqual) Error() string {
return fmt.Sprintf("branches are equal [head: %sm base: %s]", err.HeadBranchName, err.BaseBranchName)
}

func (err ErrBranchesEqual) Unwrap() error {
return util.ErrInvalidArgument
}

// ErrDisallowedToMerge represents an error that a branch is protected and the current user is not allowed to modify it.
type ErrDisallowedToMerge struct {
Reason string
Expand Down
47 changes: 47 additions & 0 deletions models/fixtures/branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-
id: 1
repo_id: 1
name: 'foo'
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
commit_message: 'first commit'
commit_time: 978307100
pusher_id: 1
is_deleted: true
deleted_by_id: 1
deleted_unix: 978307200

-
id: 2
repo_id: 1
name: 'bar'
commit_id: '62fb502a7172d4453f0322a2cc85bddffa57f07a'
commit_message: 'second commit'
commit_time: 978307100
pusher_id: 1
is_deleted: true
deleted_by_id: 99
deleted_unix: 978307200

-
id: 3
repo_id: 1
name: 'branch2'
commit_id: '985f0301dba5e7b34be866819cd15ad3d8f508ee'
commit_message: 'make pull5 outdated'
commit_time: 1579166279
pusher_id: 1
is_deleted: false
deleted_by_id: 0
deleted_unix: 0

-
id: 4
repo_id: 1
name: 'master'
commit_id: '65f1bf27bc3bf70f64657658635e66094edbcb4d'
commit_message: 'Initial commit'
commit_time: 1489927679
pusher_id: 1
is_deleted: false
deleted_by_id: 0
deleted_unix: 0
15 changes: 0 additions & 15 deletions models/fixtures/deleted_branch.yml

This file was deleted.

Loading