Skip to content

Commit c43bea2

Browse files
committed
feat: update base after integration of parent
1 parent 60c624c commit c43bea2

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

apps/desktop/src/lib/branch/SeriesHeader.svelte

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
interface Props {
3939
branch: PatchSeries;
4040
isTopSeries: boolean;
41+
isBottomSeries: boolean;
4142
lastPush: Date | undefined;
4243
}
4344
44-
const { branch, isTopSeries, lastPush }: Props = $props();
45+
const { branch, isTopSeries, isBottomSeries, lastPush }: Props = $props();
4546
4647
let descriptionVisible = $state(!!branch.description);
4748
@@ -163,6 +164,28 @@
163164
}
164165
});
165166
167+
/**
168+
* If the repository does not have "delete after merged" enabled, we need to manually update the base
169+
* of the bottom most branch to point to the projects baseBranch of choice after its parent has been integrated,
170+
* and it now is the bottom-most series.
171+
*/
172+
$effect(() => {
173+
const targetBase = $baseBranch.branchName.replace(`${$baseBranch.remoteName}/`, '');
174+
if (
175+
listedPr?.targetBranch !== targetBase &&
176+
isBottomSeries &&
177+
$prService &&
178+
$forge?.name === 'github' &&
179+
branch.prNumber &&
180+
$pr?.state === 'open'
181+
) {
182+
$prService?.update(branch.prNumber, { targetBase }).then(async () => {
183+
await $forgeListing?.refresh();
184+
await updateStatusAndChecks();
185+
});
186+
}
187+
});
188+
166189
function confirmCreatePR(close: () => void) {
167190
close();
168191
prDetailsModal?.show();

apps/desktop/src/lib/forge/github/githubPrService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,18 @@ export class GitHubPrService implements ForgePrService {
9999
return new GitHubPrMonitor(this, this.repo, prNumber, this.baseBranch);
100100
}
101101

102-
async update(prNumber: number, details: { description?: string; state?: 'open' | 'closed' }) {
103-
const { description, state } = details;
102+
async update(
103+
prNumber: number,
104+
details: { description?: string; state?: 'open' | 'closed'; targetBase?: string }
105+
) {
106+
const { description, state, targetBase } = details;
104107
await this.octokit.pulls.update({
105108
owner: this.repo.owner,
106109
repo: this.repo.name,
107110
pull_number: prNumber,
108111
body: description,
109-
state: state
112+
state: state,
113+
base: targetBase
110114
});
111115
}
112116
}

apps/desktop/src/lib/forge/interface/forgePrService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export interface ForgePrService {
2222
prMonitor(prNumber: number): ForgePrMonitor;
2323
update(
2424
prNumber: number,
25-
details: { description?: string; state?: 'open' | 'closed' }
25+
details: { description?: string; state?: 'open' | 'closed'; targetBase?: string }
2626
): Promise<void>;
2727
}

apps/desktop/src/lib/stack/SeriesList.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
{#each nonArchivedSeries as currentSeries, idx ('name' in currentSeries ? currentSeries.name : undefined)}
6464
{@const isTopSeries = idx === 0}
65-
{@const isBottomSeries = idx === branch.series.length - 1}
65+
{@const isBottomSeries = idx === nonArchivedSeries.length - 1}
6666
{#if !isTopSeries}
6767
<SeriesDividerLine
6868
topPatchStatus={isPatchSeries(currentSeries) ? currentSeries?.patches?.[0]?.status : 'error'}
@@ -71,7 +71,7 @@
7171

7272
{#if !isError(currentSeries)}
7373
<CurrentSeries {currentSeries}>
74-
<SeriesHeader branch={currentSeries} {isTopSeries} {lastPush} />
74+
<SeriesHeader branch={currentSeries} {isTopSeries} {isBottomSeries} {lastPush} />
7575

7676
{#if currentSeries.upstreamPatches.length === 0 && currentSeries.patches.length === 0}
7777
<div>

0 commit comments

Comments
 (0)