Skip to content

Commit 27b7139

Browse files
authored
Merge pull request #11449 from gitbutlerapp/copilot/dynamic-label-generation-mr
Replace hardcoded PR/MR labels with dynamic forge-based labels
2 parents 2b78a40 + 47d45db commit 27b7139

File tree

11 files changed

+52
-26
lines changed

11 files changed

+52
-26
lines changed

apps/desktop/src/components/BranchHeaderContextMenu.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@
303303
<ReduxResult {projectId} {stackId} result={prQuery?.result}>
304304
{#snippet children(pr)}
305305
<ContextMenuSection>
306-
<ContextMenuItemSubmenu label="Pull Request" icon="pr">
306+
<ContextMenuItemSubmenu label={forge.reviewUnitName} icon="pr">
307307
{#snippet submenu({ close: closeSubmenu })}
308308
<ContextMenuSection>
309309
<ContextMenuItem
310-
label="Open PR in browser"
310+
label="Open {forge.reviewUnitAbbr} in browser"
311311
testId={TestId.BranchHeaderContextMenu_OpenPRInBrowser}
312312
onclick={() => {
313313
urlService.openExternalUrl(pr.htmlUrl);
@@ -316,10 +316,12 @@
316316
}}
317317
/>
318318
<ContextMenuItem
319-
label="Copy PR link"
319+
label="Copy {forge.reviewUnitAbbr} link"
320320
testId={TestId.BranchHeaderContextMenu_CopyPRLink}
321321
onclick={() => {
322-
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
322+
clipboardService.write(pr.htmlUrl, {
323+
message: `${forge.reviewUnitAbbr} link copied`
324+
});
323325
closeSubmenu();
324326
close();
325327
}}

apps/desktop/src/components/BranchReview.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@
4949
<Modal
5050
width="small"
5151
type="warning"
52-
title="Create Pull Request"
52+
title="Create {forge.reviewUnitName}"
5353
bind:this={confirmCreatePrModal}
5454
onSubmit={() => {
5555
modal?.show();
5656
}}
5757
>
5858
<p class="text-13 text-body helper-text">
59-
It's strongly recommended to create pull requests starting with the branch at the base of the
60-
stack.
59+
It's strongly recommended to create {forge.reviewUnitName.toLowerCase()}s starting with the
60+
branch at the base of the stack.
6161
<br />
62-
Do you still want to create this pull request?
62+
Do you still want to create this {forge.reviewUnitName.toLowerCase()}?
6363
</p>
6464
{#snippet controls(close)}
6565
<Button kind="outline" onclick={close}>Cancel</Button>
66-
<Button style="warning" type="submit">Create Pull Request</Button>
66+
<Button style="warning" type="submit">Create {forge.reviewUnitName}</Button>
6767
{/snippet}
6868
</Modal>
6969

apps/desktop/src/components/BranchesView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334
icon="workbench"
335335
onclick={applyFromFork}
336336
>
337-
Apply PR to workspace
337+
Apply {forge.reviewUnitAbbr} to workspace
338338
</Button>
339339
{/if}
340340
</div>

apps/desktop/src/components/BranchesViewPR.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110

111111
<Modal
112112
testId={TestId.BranchesView_CreateRemoteModal}
113-
title="Apply Pull Request"
113+
title="Apply {forge.reviewUnitName}"
114114
width="small"
115115
bind:this={createRemoteModal}
116116
onSubmit={async () => await handleConfirmRemote(pr)}

apps/desktop/src/components/CanPublishReviewPlugin.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
const canPublishPR = $derived(forge.current.authenticated && !pr);
2828
29-
const ctaLabel = 'Create Pull Request…';
29+
const ctaLabel = $derived(`Create ${forge.reviewUnitName}…`);
3030
3131
export const imports = {
3232
get allowedToPublishPR() {

apps/desktop/src/components/PRBranchView.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
const forge = inject(DEFAULT_FORGE_FACTORY);
1717
const prService = $derived(forge.current.prService);
1818
const prQuery = $derived(prService?.get(prNumber, { forceRefetch: true }));
19-
const unitSymbol = $derived(prService?.unit.symbol ?? '');
2019
</script>
2120

2221
<ReduxResult result={prQuery?.result} {projectId} {onerror}>
2322
{#snippet children(pr)}
2423
<Drawer testId={TestId.PRBranchDrawer} persistId="pr-branch-drawer-{projectId}-{pr.number}">
2524
{#snippet header()}
2625
<h3 class="text-14 text-semibold truncate">
27-
<span class="clr-text-2">PR {unitSymbol}{pr.number}:</span>
26+
<span class="clr-text-2">{forge.reviewUnitAbbr} {forge.reviewUnitSymbol}{pr.number}:</span
27+
>
2828
<span> {pr.title}</span>
2929
</h3>
3030
{/snippet}

apps/desktop/src/components/PullRequestCard.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<ContextMenuItem
127127
label="Copy link"
128128
onclick={() => {
129-
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
129+
clipboardService.write(pr.htmlUrl, { message: `${abbr} link copied` });
130130
contextMenuEl?.close();
131131
}}
132132
/>
@@ -179,7 +179,7 @@
179179
icon="copy-small"
180180
tooltip="Copy {abbr} link"
181181
onclick={() => {
182-
clipboardService.write(pr.htmlUrl, { message: 'PR link copied' });
182+
clipboardService.write(pr.htmlUrl, { message: `${abbr} link copied` });
183183
}}
184184
/>
185185
<Button

apps/desktop/src/components/ReviewCreation.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@
423423
onClose();
424424
}
425425
})}
426-
placeholder="PR title"
426+
placeholder="{forge.reviewUnitAbbr} title"
427427
showCount={false}
428428
oninput={imeHandler.handleInput((e: Event) => {
429429
const target = e.target as HTMLInputElement;
@@ -439,8 +439,9 @@
439439
initialValue={$prBody}
440440
enableFileUpload
441441
enableSmiles
442-
placeholder="PR Description"
442+
placeholder="{forge.reviewUnitAbbr} Description"
443443
messageType="pr"
444+
reviewUnitAbbr={forge.reviewUnitAbbr}
444445
{onAiButtonClick}
445446
{canUseAI}
446447
{aiIsLoading}

apps/desktop/src/components/editor/MessageEditor.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
forceSansFont?: boolean;
6262
useRuler?: boolean;
6363
messageType: 'commit' | 'pr';
64+
reviewUnitAbbr?: string;
6465
}
6566
6667
let {
@@ -80,7 +81,8 @@
8081
testId,
8182
forceSansFont,
8283
useRuler,
83-
messageType
84+
messageType,
85+
reviewUnitAbbr
8486
}: Props = $props();
8587
8688
const MIN_RULER_VALUE = 30;
@@ -230,17 +232,17 @@
230232
medium: 320
231233
};
232234
233-
const GENERATE_MESSAGES: Record<typeof messageType, string> = {
235+
const generateMessages = $derived.by(() => ({
234236
commit: 'Generate commit message',
235-
pr: 'Generate PR description'
236-
};
237+
pr: `Generate ${reviewUnitAbbr ?? 'PR'} description`
238+
}));
237239
238240
function getTooltipText(): string | undefined {
239241
if (!canUseAI) {
240242
return 'You need to enable AI in the project settings to use this feature';
241243
}
242244
if (currentEditorWidth <= DROPDOWN_BTN_BREAKPOINTS.medium) {
243-
return GENERATE_MESSAGES[messageType];
245+
return generateMessages[messageType];
244246
}
245247
return undefined;
246248
}

apps/desktop/src/components/profileSettings/IntegrationsSettings.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
<CardGroup.Item labelFor="autoFillPrDescription">
2222
{#snippet title()}
23-
Auto-fill PR descriptions from commit
23+
Auto-fill PR/MR descriptions from commit
2424
{/snippet}
2525
{#snippet caption()}
26-
When creating a pull request for a branch with just one commit, automatically use that commit's
27-
message as the PR title and description.
26+
When creating a pull request or merge request for a branch with just one commit, automatically
27+
use that commit's message as the PR/MR title and description.
2828
{/snippet}
2929
{#snippet actions()}
3030
<Toggle

0 commit comments

Comments
 (0)