mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-30 19:08:37 +00:00 
			
		
		
		
	Backport #31151 by @lunny Fix #31140 The previous logic is wrong when pushing multiple branches. After first branch updated, it will ignore left other branches sync operations. As a workaround for the repositories, just push a new commit after the patch applied will fix the repositories status. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		| @@ -37,6 +37,41 @@ func testGitPush(t *testing.T, u *url.URL) { | ||||
| 		}) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Push branches exists", func(t *testing.T) { | ||||
| 		runTestGitPush(t, u, func(t *testing.T, gitPath string) (pushed, deleted []string) { | ||||
| 			for i := 0; i < 10; i++ { | ||||
| 				branchName := fmt.Sprintf("branch-%d", i) | ||||
| 				if i < 5 { | ||||
| 					pushed = append(pushed, branchName) | ||||
| 				} | ||||
| 				doGitCreateBranch(gitPath, branchName)(t) | ||||
| 			} | ||||
| 			// only push master and the first 5 branches | ||||
| 			pushed = append(pushed, "master") | ||||
| 			args := append([]string{"origin"}, pushed...) | ||||
| 			doGitPushTestRepository(gitPath, args...)(t) | ||||
|  | ||||
| 			pushed = pushed[:0] | ||||
| 			// do some changes for the first 5 branches created above | ||||
| 			for i := 0; i < 5; i++ { | ||||
| 				branchName := fmt.Sprintf("branch-%d", i) | ||||
| 				pushed = append(pushed, branchName) | ||||
|  | ||||
| 				doGitAddSomeCommits(gitPath, branchName)(t) | ||||
| 			} | ||||
|  | ||||
| 			for i := 5; i < 10; i++ { | ||||
| 				pushed = append(pushed, fmt.Sprintf("branch-%d", i)) | ||||
| 			} | ||||
| 			pushed = append(pushed, "master") | ||||
|  | ||||
| 			// push all, so that master are not chagned | ||||
| 			doGitPushTestRepository(gitPath, "origin", "--all")(t) | ||||
|  | ||||
| 			return pushed, deleted | ||||
| 		}) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("Push branches one by one", func(t *testing.T) { | ||||
| 		runTestGitPush(t, u, func(t *testing.T, gitPath string) (pushed, deleted []string) { | ||||
| 			for i := 0; i < 100; i++ { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user