Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/src/components/forge/ReviewCreation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@
// If we now have two or more pull requests we add a stack table to the description.
prNumbers[currentIndex] = pr.number;
const definedPrNumbers = prNumbers.filter(isDefined);
if (definedPrNumbers.length > 0) {
const enableStackFooter = $appSettings?.reviews.enableStackFooter ?? true;
if (enableStackFooter && definedPrNumbers.length > 0) {
updatePrStackInfo(prService, projectId, definedPrNumbers, forgeInfo?.unit.symbol);
}

Expand Down
21 changes: 21 additions & 0 deletions apps/desktop/src/components/settings/IntegrationsSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
autoFillPrDescriptionFromCommit: !$appSettings?.reviews.autoFillPrDescriptionFromCommit,
});
}

async function toggleStackFooter() {
await settingsService.updateReviews({
enableStackFooter: !($appSettings?.reviews.enableStackFooter ?? true),
});
}
</script>

<GithubIntegration />
Expand All @@ -36,4 +42,19 @@
/>
{/snippet}
</CardGroup.Item>
<CardGroup.Item labelFor="enableStackFooter">
{#snippet title()}
Add GitButler stack footer to PR/MR descriptions
{/snippet}
{#snippet caption()}
Append the list of pull requests in the same stack to the description.
{/snippet}
{#snippet actions()}
<Toggle
id="enableStackFooter"
checked={$appSettings?.reviews.enableStackFooter ?? true}
onclick={toggleStackFooter}
/>
{/snippet}
</CardGroup.Item>
</CardGroup>
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { FileChangeDropData, FolderChangeDropData, HunkDropDataV3 } from "$lib/dragging/draggables";
import { updateStackPrs } from "$lib/forge/shared/prFooter";
import { UNCOMMITTED_SERVICE } from "$lib/selection/uncommittedService.svelte";
import { SETTINGS_SERVICE } from "$lib/settings/appSettings";
import { normalizeReferenceSubject } from "$lib/stacks/commitMovePlacement";
import { STACK_SERVICE } from "$lib/stacks/stackService.svelte";
import { UI_STATE } from "$lib/state/uiState.svelte";
import { inject } from "@gitbutler/core/context";
import { get } from "svelte/store";
import type { DropResult } from "$lib/dragging/dropResult";
import type { DropzoneHandler } from "$lib/dragging/handler";
import type { PrService } from "$lib/forge/prService.svelte";
Expand All @@ -27,6 +29,7 @@ export class BranchDropData {

export class MoveBranchDzHandler implements DropzoneHandler {
private readonly stackService = inject(STACK_SERVICE);
private readonly settingsService = inject(SETTINGS_SERVICE);

constructor(
private readonly prService: PrService | undefined,
Expand Down Expand Up @@ -58,7 +61,10 @@ export class MoveBranchDzHandler implements DropzoneHandler {
targetBranch: normalizeReferenceSubject(this.branchName),
});

if (this.prService && this.baseBranchName) {
const enableStackFooter =
get(this.settingsService.appSettings)?.reviews.enableStackFooter ?? true;

if (enableStackFooter && this.prService && this.baseBranchName) {
if (!sourceStackDeleted) {
const branchDetails = await this.stackService.fetchBranches(this.projectId, data.stackId);
await updateStackPrs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import { BranchDropData } from "$lib/dragging/dropHandlers/branchDropHandler";
import { CommitDropData } from "$lib/dragging/dropHandlers/commitDropHandler";
import { classify } from "$lib/error/errorClassification";
import { unstackPRs, updateStackPrs } from "$lib/forge/shared/prFooter";
import { SETTINGS_SERVICE } from "$lib/settings/appSettings";
import { toCommitMovePlacement } from "$lib/stacks/commitMovePlacement";
import StackMacros from "$lib/stacks/macros";
import { toMoveBranchWarning } from "$lib/stacks/stack";
import { withStackBusy } from "$lib/state/uiState.svelte";
import { inject } from "@gitbutler/core/context";
import { untrack } from "svelte";
import { get } from "svelte/store";
import type { DropResult } from "$lib/dragging/dropResult";
import type { DropzoneHandler } from "$lib/dragging/handler";
import type { PrService } from "$lib/forge/prService.svelte";
Expand All @@ -26,6 +29,7 @@ import type { HunkAssignmentTarget } from "@gitbutler/but-sdk";
/** Handler when drop changes on a special outside lanes dropzone. */
export class OutsideLaneDzHandler implements DropzoneHandler {
private macros: StackMacros;
private readonly settingsService = inject(SETTINGS_SERVICE);

constructor(
private stackService: StackService,
Expand Down Expand Up @@ -282,6 +286,9 @@ export class OutsideLaneDzHandler implements DropzoneHandler {
}

await unstackPRs(this.prService, this.projectId, [data.prNumber], this.baseBranchName);
const enableStackFooter =
get(this.settingsService.appSettings)?.reviews.enableStackFooter ?? true;
if (!enableStackFooter) return;
const branchDetails = await this.stackService.fetchBranches(this.projectId, data.stackId);
await updateStackPrs(
this.prService,
Expand Down
4 changes: 3 additions & 1 deletion crates/but-settings/assets/defaults.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
// Settings related to code reviews and pull requests.
"reviews": {
// Whether to auto-fill PR title and description from the first commit when a branch has only one commit.
"autoFillPrDescriptionFromCommit": true
"autoFillPrDescriptionFromCommit": true,
// Whether to append the GitButler stack footer to pull request descriptions.
"enableStackFooter": true
},
// UI settings.
"ui": {
Expand Down
4 changes: 4 additions & 0 deletions crates/but-settings/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct ClaudeUpdate {
/// Update request for [`crate::app_settings::Reviews`].
pub struct ReviewsUpdate {
pub auto_fill_pr_description_from_commit: Option<bool>,
pub enable_stack_footer: Option<bool>,
}

#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -163,6 +164,9 @@ impl AppSettingsWithDiskSync {
settings.reviews.auto_fill_pr_description_from_commit =
auto_fill_pr_description_from_commit;
}
if let Some(enable_stack_footer) = update.enable_stack_footer {
settings.reviews.enable_stack_footer = enable_stack_footer;
}
settings.save()
}

Expand Down
2 changes: 2 additions & 0 deletions crates/but-settings/src/app_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ but_schemars::register_sdk_type!(Claude);
pub struct Reviews {
/// Whether to auto-fill PR title and description from the first commit when a branch has only one commit.
pub auto_fill_pr_description_from_commit: bool,
/// Whether to append the GitButler stack footer to pull request descriptions.
pub enable_stack_footer: bool,
}
but_schemars::register_sdk_type!(Reviews);

Expand Down
1 change: 1 addition & 0 deletions crates/but-testsupport/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ impl Sandbox {
},
reviews: Reviews {
auto_fill_pr_description_from_commit: false,
enable_stack_footer: true,
},
ui: UiSettings {
use_native_title_bar: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/but-sdk/src/generated/graph/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ export interface WatcherEvent {
* `callback` receives watcher events shaped as `{ name, payload }`.
*/
export declare function watcherStart(projectId: string, callback: ((err: Error | null, arg: WatcherEvent) => any)): Promise<WatcherHandle>

// Auto-generated by but-ts. Do not edit manually.
// Generated from JSON schemas registered by #[but_api] functions.

Expand Down Expand Up @@ -2416,6 +2417,8 @@ export type ReviewTemplateInfo = {
export type Reviews = {
/** Whether to auto-fill PR title and description from the first commit when a branch has only one commit. */
autoFillPrDescriptionFromCommit: boolean;
/** Whether to append the GitButler stack footer to pull request descriptions. */
enableStackFooter: boolean;
};

/** A segment of a commit graph, representing a set of commits exclusively. */
Expand Down
3 changes: 3 additions & 0 deletions packages/but-sdk/src/generated/linear/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ export interface WatcherEvent {
* `callback` receives watcher events shaped as `{ name, payload }`.
*/
export declare function watcherStart(projectId: string, callback: ((err: Error | null, arg: WatcherEvent) => any)): Promise<WatcherHandle>

// Auto-generated by but-ts. Do not edit manually.
// Generated from JSON schemas registered by #[but_api] functions.

Expand Down Expand Up @@ -2416,6 +2417,8 @@ export type ReviewTemplateInfo = {
export type Reviews = {
/** Whether to auto-fill PR title and description from the first commit when a branch has only one commit. */
autoFillPrDescriptionFromCommit: boolean;
/** Whether to append the GitButler stack footer to pull request descriptions. */
enableStackFooter: boolean;
};

/** A segment of a commit graph, representing a set of commits exclusively. */
Expand Down