Skip to content

Commit e3ade4e

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Retarget depending pulls when the parent branch is deleted (go-gitea#28686) Bump `@github/relative-time-element` to 4.3.1 (go-gitea#28819) Fix reverting a merge commit failing (go-gitea#28794) Render code block in activity tab (go-gitea#28816) Remove trust model selection from repository creation on web page because it can be changed in settings later (go-gitea#28814)
2 parents b112684 + 49eb168 commit e3ade4e

File tree

33 files changed

+270
-79
lines changed

33 files changed

+270
-79
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,9 @@ LEVEL = Info
10671067
;;
10681068
;; In addition to testing patches using the three-way merge method, re-test conflicting patches with git apply
10691069
;TEST_CONFLICTING_PATCHES_WITH_GIT_APPLY = false
1070+
;;
1071+
;; Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo.
1072+
;RETARGET_CHILDREN_ON_MERGE = true
10701073

10711074
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10721075
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ In addition, there is _`StaticRootPath`_ which can be set as a built-in at build
135135
- `POPULATE_SQUASH_COMMENT_WITH_COMMIT_MESSAGES`: **false**: In default squash-merge messages include the commit message of all commits comprising the pull request.
136136
- `ADD_CO_COMMITTER_TRAILERS`: **true**: Add co-authored-by and co-committed-by trailers to merge commit messages if committer does not match author.
137137
- `TEST_CONFLICTING_PATCHES_WITH_GIT_APPLY`: **false**: PR patches are tested using a three-way merge method to discover if there are conflicts. If this setting is set to **true**, conflicting patches will be retested using `git apply` - This was the previous behaviour in 1.18 (and earlier) but is somewhat inefficient. Please report if you find that this setting is required.
138+
- `RETARGET_CHILDREN_ON_MERGE`: **true**: Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo.
138139

139140
### Repository - Issue (`repository.issue`)
140141

models/fixtures/repo_unit.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,10 @@
669669
type: 10
670670
config: "{}"
671671
created_unix: 946684810
672+
673+
-
674+
id: 101
675+
repo_id: 59
676+
type: 1
677+
config: "{}"
678+
created_unix: 946684810

models/fixtures/repository.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,3 +1693,16 @@
16931693
size: 0
16941694
is_fsck_enabled: true
16951695
close_issues_via_commit_in_any_branch: false
1696+
1697+
-
1698+
id: 59
1699+
owner_id: 2
1700+
owner_name: user2
1701+
lower_name: test_commit_revert
1702+
name: test_commit_revert
1703+
default_branch: main
1704+
is_empty: false
1705+
is_archived: false
1706+
is_private: true
1707+
status: 0
1708+
num_issues: 0

models/fixtures/user.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
num_followers: 2
6767
num_following: 1
6868
num_stars: 2
69-
num_repos: 14
69+
num_repos: 15
7070
num_teams: 0
7171
num_members: 0
7272
visibility: 0

modules/setting/repository.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ var (
8585
PopulateSquashCommentWithCommitMessages bool
8686
AddCoCommitterTrailers bool
8787
TestConflictingPatchesWithGitApply bool
88+
RetargetChildrenOnMerge bool
8889
} `ini:"repository.pull-request"`
8990

9091
// Issue Setting
@@ -209,6 +210,7 @@ var (
209210
PopulateSquashCommentWithCommitMessages bool
210211
AddCoCommitterTrailers bool
211212
TestConflictingPatchesWithGitApply bool
213+
RetargetChildrenOnMerge bool
212214
}{
213215
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
214216
// Same as GitHub. See
@@ -223,6 +225,7 @@ var (
223225
DefaultMergeMessageOfficialApproversOnly: true,
224226
PopulateSquashCommentWithCommitMessages: false,
225227
AddCoCommitterTrailers: true,
228+
RetargetChildrenOnMerge: true,
226229
},
227230

228231
// Issue settings

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"@citation-js/plugin-software-formats": "0.6.1",
1111
"@claviska/jquery-minicolors": "2.3.6",
1212
"@github/markdown-toolbar-element": "2.2.1",
13-
"@github/relative-time-element": "4.3.0",
13+
"@github/relative-time-element": "4.3.1",
1414
"@github/text-expander-element": "2.6.1",
1515
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1616
"@primer/octicons": "19.8.0",

routers/api/v1/repo/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,10 @@ func MergePullRequest(ctx *context.APIContext) {
913913
}
914914
defer headRepo.Close()
915915
}
916+
if err := pull_service.RetargetChildrenOnMerge(ctx, ctx.Doer, pr); err != nil {
917+
ctx.Error(http.StatusInternalServerError, "RetargetChildrenOnMerge", err)
918+
return
919+
}
916920
if err := repo_service.DeleteBranch(ctx, ctx.Doer, pr.HeadRepo, headRepo, pr.HeadBranch); err != nil {
917921
switch {
918922
case git.IsErrBranchNotExist(err):

routers/web/repo/pull.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,12 @@ func CleanUpPullRequest(ctx *context.Context) {
15871587

15881588
func deleteBranch(ctx *context.Context, pr *issues_model.PullRequest, gitRepo *git.Repository) {
15891589
fullBranchName := pr.HeadRepo.FullName() + ":" + pr.HeadBranch
1590+
1591+
if err := pull_service.RetargetChildrenOnMerge(ctx, ctx.Doer, pr); err != nil {
1592+
ctx.Flash.Error(ctx.Tr("repo.branch.deletion_failed", fullBranchName))
1593+
return
1594+
}
1595+
15901596
if err := repo_service.DeleteBranch(ctx, ctx.Doer, pr.HeadRepo, gitRepo, pr.HeadBranch); err != nil {
15911597
switch {
15921598
case git.IsErrBranchNotExist(err):

0 commit comments

Comments
 (0)