Skip to content

Comments

Preserve the history of the diffs of the MR#1

Open
poautran wants to merge 6 commits intomasterfrom
closed-mr-point-at-right-version-of-main
Open

Preserve the history of the diffs of the MR#1
poautran wants to merge 6 commits intomasterfrom
closed-mr-point-at-right-version-of-main

Conversation

@poautran
Copy link
Owner

@poautran poautran commented Jan 7, 2026

No description provided.

Copy link
Collaborator

@loichuder loichuder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, looks ok to me.

There are probably some typing issues that will arise here and there when doing the actual PR.

It might also be worthwhile splitting the PR in several since this fixes several issues at once.

mergeRequests: {
logFile: string;
log: boolean;
replayMergedRequests?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
replayMergedRequests?: boolean;
replayMergedRequests: boolean;

Might be more explicit to keep it a required setting

Comment on lines +545 to +546
const aMerged = a.merged_at ? new Date(a.merged_at).getTime() : 0;
const bMerged = b.merged_at ? new Date(b.merged_at).getTime() : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const aMerged = a.merged_at ? new Date(a.merged_at).getTime() : 0;
const bMerged = b.merged_at ? new Date(b.merged_at).getTime() : 0;
const aMergeDate = a.merged_at ? new Date(a.merged_at).getTime() : 0;
const bMergeDate = b.merged_at ? new Date(b.merged_at).getTime() : 0;

Comment on lines +541 to +542
// Sort merge requests in ascending order of their number (by iid), unless
// we are replaying merged requests in chronological merge order.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Sort merge requests in ascending order of their number (by iid), unless
// we are replaying merged requests in chronological merge order.
// Sort merge requests in chronological merge order instead of iid if replaying them

mergeRequestIid: number
): Promise<GitLabMergeRequest | null> {
try {
return await this.gitlabApi.MergeRequests.show(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, you don't have to call await if you return a Promise.

Suggested change
return await this.gitlabApi.MergeRequests.show(
return this.gitlabApi.MergeRequests.show(

const originalSourceBranch = mergeRequest.source_branch;

if (replayMerged) {
await this.resetTargetBranchForMergeRequest(mergeRequest, false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a point in keeping the restore bool if it is always set to false?

if (!mergeRequest.reviewers) return [];
let reviewers: string[] = [];
for (let reviewer of mergeRequest.reviewers) {
let username: string = reviewer.username as string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type annotation is not needed since it is cast to string.

Suggested change
let username: string = reviewer.username as string;
let username = reviewer.username as string;

if (username === settings.github.username) {
reviewers.push(settings.github.username);
} else if (settings.usermap && settings.usermap[username]) {
let gitHubUsername = settings.usermap[username];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let gitHubUsername = settings.usermap[username];
const gitHubUsername = settings.usermap[username];


private async ensureTempBranchForMergeRequest(
mergeRequest: GitLabMergeRequest
): Promise<null | { name: string; created: boolean }> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with the other type annotations of the project, { name: string; created: boolean } should be a TS interface.

Comment on lines +1347 to +1348
const mergedBy = (mergeRequest as any).merged_by?.username;
const mergedAt = (mergeRequest as any).merged_at;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These as any casts should not be needed if the GitLabMergeRequest type is correct.

static createReviewCommentInformation(
position,
repoLink: string
): object | null {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change in type here does not do anything: null is an object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants