GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(gitlab): merge request details report their head commit (#18608) · pingdotgg/t3code@a3c4e9e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/source-control-gitlab/src/server
    • gitLabMergeRequestJson.test.ts
    • gitLabMergeRequestJson.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts‎

Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ describe("decodeMergeRequestDetailJson", () => {
181181
expect(detail.changedFiles).toBe(0);
182182
});
183183

184+
it("reads the head commit, and says nothing where GitLab omitted it", () => {
185+
const headSha = (entry: Record<string, unknown>) =>
186+
expectSuccess(decodeMergeRequestDetailJson(detailJson(entry))).headSha;
187+
const sha = "afce4da4d5fe7d2fd0647b5b864526ea0a2827cb";
188+
189+
expect(headSha({ sha })).toBe(sha);
190+
// A new merge request can report its head before GitLab has computed `diff_refs`.
191+
expect(headSha({ sha, diff_refs: null })).toBe(sha);
192+
expect(headSha({ sha, merge_commit_sha: "0".repeat(40) })).toBe(sha);
193+
expect(headSha({})).toBeUndefined();
194+
expect(headSha({ sha: null })).toBeUndefined();
195+
expect(headSha({ sha: " " })).toBeUndefined();
196+
});
197+
184198
it("reads either auto-merge field, and says nothing where GitLab named neither", () => {
185199
const armed = (entry: Record<string, unknown>) =>
186200
expectSuccess(decodeMergeRequestDetailJson(detailJson(entry))).autoMergeEnabled;
Collapse file

‎packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts‎

Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const RawMergeRequestSchema = Schema.Struct({
5151
author: Schema.optional(Schema.NullOr(RawUserSchema)),
5252
source_branch: Schema.String,
5353
target_branch: Schema.String,
54+
/** The source branch's head commit. */
55+
sha: Schema.optional(Schema.NullOr(Schema.String)),
5456
state: Schema.optional(Schema.NullOr(Schema.String)),
5557
draft: Schema.optional(Schema.Boolean),
5658
work_in_progress: Schema.optional(Schema.Boolean),
@@ -240,6 +242,8 @@ export interface GitLabMergeRequestDetail extends GitLabMergeRequestListItem {
240242
* it: an install too old to answer must not be read as saying the branch is current.
241243
*/
242244
readonly divergedCommits?: number;
245+
/** Absent where GitLab did not report the head commit. */
246+
readonly headSha?: string;
243247
}
244248

245249
function trimmed(value: string | null | undefined): string | null {
@@ -365,6 +369,7 @@ function toListItem(
365369

366370
function toDetail(raw: Schema.Schema.Type<typeof RawMergeRequestSchema>): GitLabMergeRequestDetail {
367371
const listItem = toListItem(raw);
372+
const headSha = trimmed(raw.sha);
368373
const autoMerge =
369374
raw.merge_when_pipeline_succeeds == null && raw.auto_merge_enabled == null
370375
? undefined
@@ -390,6 +395,7 @@ function toDetail(raw: Schema.Schema.Type<typeof RawMergeRequestSchema>): GitLab
390395
? { autoMergeMethod: "squash" as const }
391396
: {}),
392397
...(raw.diverged_commits_count == null ? {} : { divergedCommits: raw.diverged_commits_count }),
398+
...(headSha === null ? {} : { headSha }),
393399
};
394400
}
395401

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.