Skip to content

Commit 6249394

Browse files
committed
fix(gitlab): tri-state controls for update-op booleans (executable flag, MR squash/remove-source-branch)
1 parent 8df5a09 commit 6249394

1 file changed

Lines changed: 66 additions & 16 deletions

File tree

apps/sim/blocks/blocks/gitlab.ts

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ function parseJsonParam(raw: unknown, label: string): any {
114114
return parsed
115115
}
116116

117+
/** Maps a "Leave unchanged / Yes / No" dropdown value to true, false, or undefined. */
118+
function parseTriState(raw: unknown): boolean | undefined {
119+
if (raw === 'true' || raw === true) return true
120+
if (raw === 'false' || raw === false) return false
121+
return undefined
122+
}
123+
117124
export const GitLabBlock: BlockConfig<GitLabResponse> = {
118125
type: 'gitlab',
119126
name: 'GitLab',
@@ -887,11 +894,41 @@ Return ONLY the timestamp string - no explanations, no extra text.`,
887894
mode: 'advanced',
888895
condition: {
889896
field: 'operation',
890-
value: [
891-
'gitlab_create_merge_request',
892-
'gitlab_update_merge_request',
893-
'gitlab_merge_merge_request',
894-
],
897+
value: ['gitlab_create_merge_request', 'gitlab_merge_merge_request'],
898+
},
899+
},
900+
// Tri-state variants for Update MR: a switch cannot express "turn this
901+
// off" without also clobbering the setting on every unrelated update.
902+
{
903+
id: 'updateRemoveSourceBranch',
904+
title: 'Remove Source Branch',
905+
type: 'dropdown',
906+
options: [
907+
{ label: 'Leave unchanged', id: '' },
908+
{ label: 'Yes', id: 'true' },
909+
{ label: 'No', id: 'false' },
910+
],
911+
value: () => '',
912+
mode: 'advanced',
913+
condition: {
914+
field: 'operation',
915+
value: ['gitlab_update_merge_request'],
916+
},
917+
},
918+
{
919+
id: 'updateSquash',
920+
title: 'Squash Commits',
921+
type: 'dropdown',
922+
options: [
923+
{ label: 'Leave unchanged', id: '' },
924+
{ label: 'Yes', id: 'true' },
925+
{ label: 'No', id: 'false' },
926+
],
927+
value: () => '',
928+
mode: 'advanced',
929+
condition: {
930+
field: 'operation',
931+
value: ['gitlab_update_merge_request'],
895932
},
896933
},
897934
// Squash commits
@@ -902,11 +939,7 @@ Return ONLY the timestamp string - no explanations, no extra text.`,
902939
mode: 'advanced',
903940
condition: {
904941
field: 'operation',
905-
value: [
906-
'gitlab_create_merge_request',
907-
'gitlab_update_merge_request',
908-
'gitlab_merge_merge_request',
909-
],
942+
value: ['gitlab_create_merge_request', 'gitlab_merge_merge_request'],
910943
},
911944
},
912945
// Merge commit message
@@ -1273,9 +1306,14 @@ Return ONLY the JSON array - no explanations, no extra text.`,
12731306
{
12741307
id: 'executeFilemode',
12751308
title: 'Executable',
1276-
type: 'switch',
1309+
type: 'dropdown',
1310+
options: [
1311+
{ label: 'Leave unchanged', id: '' },
1312+
{ label: 'Enabled', id: 'true' },
1313+
{ label: 'Disabled', id: 'false' },
1314+
],
1315+
value: () => '',
12771316
mode: 'advanced',
1278-
description: 'Enable the execute flag on the file',
12791317
condition: {
12801318
field: 'operation',
12811319
value: ['gitlab_create_file', 'gitlab_update_file'],
@@ -2079,8 +2117,8 @@ Return ONLY the JSON array - no explanations, no extra text.`,
20792117
: undefined,
20802118
milestoneId: params.milestoneId ? Number(params.milestoneId) : undefined,
20812119
stateEvent: params.stateEvent || undefined,
2082-
removeSourceBranch: params.removeSourceBranch || undefined,
2083-
squash: params.squash || undefined,
2120+
removeSourceBranch: parseTriState(params.updateRemoveSourceBranch),
2121+
squash: parseTriState(params.updateSquash),
20842122
}
20852123

20862124
case 'gitlab_merge_merge_request':
@@ -2215,7 +2253,7 @@ Return ONLY the JSON array - no explanations, no extra text.`,
22152253
startBranch: params.startBranch?.trim() || undefined,
22162254
authorName: params.authorName?.trim() || undefined,
22172255
authorEmail: params.authorEmail?.trim() || undefined,
2218-
executeFilemode: params.executeFilemode || undefined,
2256+
executeFilemode: parseTriState(params.executeFilemode),
22192257
...(params.operation === 'gitlab_update_file'
22202258
? { lastCommitId: params.lastCommitId?.trim() || undefined }
22212259
: {}),
@@ -2735,7 +2773,10 @@ Return ONLY the JSON array - no explanations, no extra text.`,
27352773
startBranch: { type: 'string', description: 'Base branch for new-branch file commits' },
27362774
authorName: { type: 'string', description: 'Commit author name override' },
27372775
authorEmail: { type: 'string', description: 'Commit author email override' },
2738-
executeFilemode: { type: 'boolean', description: 'Enable the execute flag on the file' },
2776+
executeFilemode: {
2777+
type: 'string',
2778+
description: "Execute flag on the file ('true', 'false', or '' to leave unchanged)",
2779+
},
27392780
fromProjectId: { type: 'string', description: 'Project to compare from (cross-fork)' },
27402781
unidiff: { type: 'boolean', description: 'Return diffs in unified diff format' },
27412782
internalNote: { type: 'boolean', description: 'Create the comment as an internal note' },
@@ -2750,6 +2791,15 @@ Return ONLY the JSON array - no explanations, no extra text.`,
27502791
pipelineStatus: { type: 'string', description: 'Pipeline status filter' },
27512792
removeSourceBranch: { type: 'boolean', description: 'Remove source branch after merge' },
27522793
squash: { type: 'boolean', description: 'Squash commits on merge' },
2794+
updateSquash: {
2795+
type: 'string',
2796+
description: "Squash setting on MR update ('true', 'false', or '' to leave unchanged)",
2797+
},
2798+
updateRemoveSourceBranch: {
2799+
type: 'string',
2800+
description:
2801+
"Remove-source-branch setting on MR update ('true', 'false', or '' to leave unchanged)",
2802+
},
27532803
mergeCommitMessage: { type: 'string', description: 'Custom merge commit message' },
27542804
perPage: { type: 'number', description: 'Results per page' },
27552805
page: { type: 'number', description: 'Page number' },

0 commit comments

Comments
 (0)