mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-10 20:18:30 +00:00
fix: make "edit pr title & target branch" get correct branch (#39612)
* Fix #39610 * Regression of #39262 Also, the old code is very fragile: `#branch_target` is from translation string, so refactored it together --------- Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
4e2c3e43f2
commit
b1726adebb
3 files changed
+36
-8
No files matched your search
@@ -397,12 +397,13 @@ export function initRepoIssueTitleEdit() {
|
||||
});
|
||||
|
||||
const pullDescEditor = document.querySelector('#pull-desc-editor'); // it may not exist for a merged PR
|
||||
const pullTargetBranch = document.querySelector('#pull-target-branch');
|
||||
const prTargetUpdateUrl = pullDescEditor?.getAttribute('data-target-update-url');
|
||||
|
||||
pullDescEditor?.querySelector('#branch-select')?.addEventListener('click', (e: Event) => {
|
||||
const el = (e.target as HTMLElement).closest('.item[data-branch]');
|
||||
if (!el) return;
|
||||
const pullTargetBranch = pullDescEditor.querySelector('#pull-target-branch')!;
|
||||
if (!pullTargetBranch) throw new Error('pullTargetBranch not found');
|
||||
const textCompareBase = pullTargetBranch.getAttribute('data-text-compare-base')!;
|
||||
const baseUserName = pullTargetBranch.getAttribute('data-base-user-name')!;
|
||||
const branchNameNew = el.getAttribute('data-branch')!;
|
||||
@@ -422,8 +423,9 @@ export function initRepoIssueTitleEdit() {
|
||||
}
|
||||
}
|
||||
if (prTargetUpdateUrl) {
|
||||
const newTargetBranch = document.querySelector('#pull-target-branch')!.getAttribute('data-branch');
|
||||
const oldTargetBranch = document.querySelector('#branch_target')!.textContent;
|
||||
if (!pullTargetBranch) throw new Error('pullTargetBranch not found');
|
||||
const newTargetBranch = pullTargetBranch.getAttribute('data-branch');
|
||||
const oldTargetBranch = pullTargetBranch.getAttribute('data-old-target-branch');
|
||||
if (newTargetBranch !== oldTargetBranch) {
|
||||
const resp = await POST(prTargetUpdateUrl, {data: new URLSearchParams({target_branch: String(newTargetBranch)})});
|
||||
if (!resp.ok) {
|
||||
|
||||
Reference in new issue
Block a user