History

fix(pull-requests): missing features & better behaviour (#9188)

maria committed 2 months ago

Commit 443b4eb1 parent 4ba39a634 files · +2241 −205Browse files

Showing the changes to apps/server/src/pullRequest/gitLabMergeRequestJson.ts (1 of 34 files). Show all

Unified · Split

apps/server/src/pullRequest/gitLabMergeRequestJson.ts+9−0
@@ -11,6 +11,7 @@ import type { · 10 unmodified lines
1111 PullRequestLabel,
1212 PullRequestMergeability,
1313 PullRequestMergeCapabilities,
14+ PullRequestMergeMethod,
1415 PullRequestReaction,
1516 PullRequestReactionContent,
1617 PullRequestReviewThread,
@@ -80,6 +81,9 @@ const RawMergeRequestSchema = Schema.Struct({ · 63 unmodified lines
8081 */
8182 merge_when_pipeline_succeeds: Schema.optional(Schema.NullOr(Schema.Boolean)),
8283 auto_merge_enabled: Schema.optional(Schema.NullOr(Schema.Boolean)),
84+ /** The merge request's stored squash choice, including project-policy overrides. */
85+ squash_on_merge: Schema.optional(Schema.NullOr(Schema.Boolean)),
86+ squash: Schema.optional(Schema.NullOr(Schema.Boolean)),
8387 /**
8488 * How far the target branch has moved on since this one left it, which is the same number
8589 * GitLab's own "out of date" wording counts. It costs a walk of the two branches, so GitLab
@@ -228,6 +232,8 @@ export interface GitLabMergeRequestDetail extends GitLabMergeRequestListItem { · 142 unmodified lines
228232 readonly reviewerIds: ReadonlyArray<number>;
229233 /** Absent where GitLab named neither auto-merge field, which is not the same as off. */
230234 readonly autoMergeEnabled?: boolean;
235+ /** GitLab only exposes the stored strategy separately when that strategy is squash. */
236+ readonly autoMergeMethod?: PullRequestMergeMethod;
231237 /**
232238 * Absent where GitLab did not count, which is not the same as a branch that has nothing behind
233239 * it: an install too old to answer must not be read as saying the branch is current.
@@ -379,6 +385,9 @@ function toDetail(raw: Schema.Schema.Type<typeof RawMergeRequestSchema>): GitLab · 145 unmodified lines
379385 reviewer.id === undefined ? [] : [reviewer.id],
380386 ),
381387 ...(autoMerge === undefined ? {} : { autoMergeEnabled: autoMerge }),
388+ ...(autoMerge === true && raw.squash_on_merge === true
389+ ? { autoMergeMethod: "squash" as const }
390+ : {}),
382391 ...(raw.diverged_commits_count == null ? {} : { divergedCommits: raw.diverged_commits_count }),
383392 };
384393 }