Repository navigation
fix(CI): retry /forcemerge with squash and merge when rebase fails - #823
Conversation
Reviewer's GuideConfigurationAdd SPDX headers and update the ChatOps
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
54c57ee to
6229977
Compare
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/chatOps.yml" line_range="395" />
<code_context>
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ pull_number: context.issue.number,
+ merge_method: mergeMethod
+ })
+ } catch (error) {
</code_context>
<issue_to_address>
**Fallback remains disabled for target repository**
When `/forcemerge` runs in `dtkdeclarative` and rebase is rejected, gitHub rejects the `merge` fallback because `organization.yaml` lists `dtkdeclarative` among repositories with `allow_merge_commit` disabled; the error propagates, so `/forcemerge` still cannot merge the reported PR.
Enable merge commits for `dtkdeclarative`, or use a fallback method permitted by its repository settings.
</issue_to_address>
### Comment 2
<location path=".github/workflows/chatOps.yml" line_range="404" />
<code_context>
owner: context.repo.owner,
repo: context.repo.repo,
- body: `This pr force merged! (status: ${pull.data.mergeable_state})`
+ body: `This pr force merged! (status: ${pull.data.mergeable_state}, merge_method: ${mergeMethod})`
})
}
</code_context>
<issue_to_address>
**Merged PR loses success notice**
When the merge succeeds but the post-merge comment request fails or the job stops before it completes, `issues.createComment` can fail after the merge, leaving the PR merged without a force-merge comment; an uncaught API error also marks the workflow run as failed, and retrying `/forcemerge` attempts the merge again and exits before restoring the comment.
Make post-merge comment delivery recoverable without rerunning the merge, and handle comment API errors separately from merge success.
</issue_to_address>
### Comment 3
<location path=".github/workflows/chatOps.yml" line_range="404" />
<code_context>
owner: context.repo.owner,
repo: context.repo.repo,
- body: `This pr force merged! (status: ${pull.data.mergeable_state})`
+ body: `This pr force merged! (status: ${pull.data.mergeable_state}, merge_method: ${mergeMethod})`
})
}
</code_context>
<issue_to_address>
**Fallback merge goes unreported**
When the rebase attempt is rejected, the merge-method fallback succeeds, and the fetched PR state is `clean`, `pull.data.mergeable_state` is `clean`, so the guard at line 399 skips `createComment` even after `mergeMethod` changes to `merge`; users get no success notice or indication that the fallback merge method was used.
Post the success comment after any successful fallback merge, regardless of the initial mergeable state.
</issue_to_address>
### Comment 4
<location path=".github/workflows/chatOps.yml" line_range="374" />
<code_context>
pull_number: context.issue.number,
})
+ // A rebase merge keeps the history linear, but GitHub rejects it with
+ // 405 "This branch can't be rebased" when the PR branch contains merge
+ // commits or conflicts with the base branch (e.g. a sync PR merging
</code_context>
<issue_to_address>
**Modified workflow lacks copyright year**
When this pull request modifies `.github/workflows/chatOps.yml` without adding an SPDX header, `.github/workflows/chatOps.yml` has no SPDX copyright header, so this modification leaves the file without the required copyright-year update.
Add the required SPDX copyright and license header, with the copyright year updated through 2026.
</issue_to_address>| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: context.issue.number, | ||
| merge_method: mergeMethod |
There was a problem hiding this comment.
🟠 High · Fallback remains disabled for target repository
When /forcemerge runs in dtkdeclarative and rebase is rejected, gitHub rejects the merge fallback because organization.yaml lists dtkdeclarative among repositories with allow_merge_commit disabled; the error propagates, so /forcemerge still cannot merge the reported PR.
Enable merge commits for dtkdeclarative, or use a fallback method permitted by its repository settings.
Prompt for AI agents
In `.github/workflows/chatOps.yml` at line 395:
**Fallback remains disabled for target repository**
When `/forcemerge` runs in `dtkdeclarative` and rebase is rejected, gitHub rejects the `merge` fallback because `organization.yaml` lists `dtkdeclarative` among repositories with `allow_merge_commit` disabled; the error propagates, so `/forcemerge` still cannot merge the reported PR.
Enable merge commits for `dtkdeclarative`, or use a fallback method permitted by its repository settings.| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `This pr force merged! (status: ${pull.data.mergeable_state})` | ||
| body: `This pr force merged! (status: ${pull.data.mergeable_state}, merge_method: ${mergeMethod})` |
There was a problem hiding this comment.
🟡 Medium · Merged PR loses success notice
When the merge succeeds but the post-merge comment request fails or the job stops before it completes, issues.createComment can fail after the merge, leaving the PR merged without a force-merge comment; an uncaught API error also marks the workflow run as failed, and retrying /forcemerge attempts the merge again and exits before restoring the comment.
Make post-merge comment delivery recoverable without rerunning the merge, and handle comment API errors separately from merge success.
Prompt for AI agents
In `.github/workflows/chatOps.yml` at line 404:
**Merged PR loses success notice**
When the merge succeeds but the post-merge comment request fails or the job stops before it completes, `issues.createComment` can fail after the merge, leaving the PR merged without a force-merge comment; an uncaught API error also marks the workflow run as failed, and retrying `/forcemerge` attempts the merge again and exits before restoring the comment.
Make post-merge comment delivery recoverable without rerunning the merge, and handle comment API errors separately from merge success.6229977 to
102b9b3
Compare
102b9b3 to
8765f1e
Compare
GitHub rejects a merge method that cannot be applied to the PR with 405/409, e.g. "This branch can't be rebased" for a sync PR that merges master into a release branch. /forcemerge then fails silently after posting "This pr force merged!". Try rebase first, then squash, and fall back to a merge commit as the last resort, reporting the method used. Post the success comment whenever a fallback method was used, even if the PR was already clean, so the method switch is not silent. Add the SPDX copyright header with the year range 2022-2026.
8765f1e to
5c248ef
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, hudeng-go The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
问题
/forcemerge在部分 PR 上无法合并,GitHub API 返回:例如 linuxdeepin/dtkdeclarative#760(
chore: merge master into v25-flowstyle)。该 PR 的 head 是一个 merge commit,v25-flowstyle..head有 32 个提交;GitHub 的 rebase 合并需要把这些提交重放到 base 上,与 base 分支的改动冲突(qt6/src/qml/ArrowListView.qml),因此 rebase 方式不可用。修改
forcemerge步骤按 rebase → squash → merge 的顺序尝试合并:某一种方式被 GitHub 以 405/409 拒绝(如This branch can't be rebased)时换下一种,三种都失败才抛错并汇总各方式的原因;非 405/409 的错误(权限、参数等)直接抛出。squash/merge),就发送This pr force merged!注释并在内容里带上实际使用的merge_method,即使合并前mergeable_state已经是clean;原来只在状态非 clean 时才发注释,回退成功是静默的。.github/copilot-instructions.md的要求补上 SPDX 头(该文件创建于 2022 年、本次修改于 2026 年,使用2022-2026范围格式)。验证
yaml.safe_load通过;内嵌脚本node --check通过。rebase;rebase 405 →squash;两者都失败 →merge;三种都失败 → 抛出汇总错误;403 等直接抛出。git rebase冲突,git merge干净通过(base 是 head 的祖先,fast-forward)。备注
/merge步骤同样硬编码merge_method: 'rebase',但它只在mergeable_state == "clean"时才会走到合并,本次未改动。