Skip to content
Merged
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
221 changes: 217 additions & 4 deletions apps/sim/blocks/blocks/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ export const GitLabBlock: BlockConfig<GitLabResponse> = {
{ label: 'List Commits', id: 'gitlab_list_commits' },
{ label: 'List Branches', id: 'gitlab_list_branches' },
{ label: 'Create Branch', id: 'gitlab_create_branch' },
{ label: 'Delete Branch', id: 'gitlab_delete_branch' },
{ label: 'Compare Branches', id: 'gitlab_compare_branches' },
// Additional Merge Request Operations
{ label: 'Get MR Changes', id: 'gitlab_get_merge_request_changes' },
{ label: 'Approve Merge Request', id: 'gitlab_approve_merge_request' },
// Job Operations
{ label: 'List Pipeline Jobs', id: 'gitlab_list_pipeline_jobs' },
{ label: 'Get Job Log', id: 'gitlab_get_job_log' },
{ label: 'Play Job', id: 'gitlab_play_job' },
// Release Operations
{ label: 'List Releases', id: 'gitlab_list_releases' },
{ label: 'Create Release', id: 'gitlab_create_release' },
],
value: () => 'gitlab_list_projects',
},
Expand Down Expand Up @@ -116,11 +121,15 @@ export const GitLabBlock: BlockConfig<GitLabResponse> = {
'gitlab_list_commits',
'gitlab_list_branches',
'gitlab_create_branch',
'gitlab_delete_branch',
'gitlab_compare_branches',
'gitlab_get_merge_request_changes',
'gitlab_approve_merge_request',
'gitlab_list_pipeline_jobs',
'gitlab_get_job_log',
'gitlab_play_job',
'gitlab_list_releases',
'gitlab_create_release',
],
},
},
Expand Down Expand Up @@ -210,16 +219,18 @@ Return ONLY the title - no explanations, no extra text.`,
'gitlab_update_issue',
'gitlab_create_merge_request',
'gitlab_update_merge_request',
'gitlab_create_release',
],
},
wandConfig: {
enabled: true,
prompt: `Generate a comprehensive description for a GitLab issue or merge request based on the user's request.
prompt: `Generate a comprehensive description for a GitLab issue, merge request, or release based on the user's request.
Include relevant sections as appropriate:
- Summary of changes or problem
- Context and motivation
- Testing done (for MRs)
- Steps to reproduce (for bugs)
- Highlights and notable changes (for releases)

Use Markdown formatting for readability.

Expand Down Expand Up @@ -278,11 +289,19 @@ Return ONLY the comment text - no explanations, no extra formatting.`,
title: 'Branch/Tag',
type: 'short-input',
placeholder: 'Enter branch or tag name',
required: true,
condition: {
required: {
field: 'operation',
value: ['gitlab_create_pipeline', 'gitlab_get_file', 'gitlab_create_branch'],
},
condition: {
field: 'operation',
value: [
'gitlab_create_pipeline',
'gitlab_get_file',
'gitlab_create_branch',
'gitlab_create_release',
],
},
},
// File Path
{
Expand All @@ -305,7 +324,102 @@ Return ONLY the comment text - no explanations, no extra formatting.`,
required: true,
condition: {
field: 'operation',
value: ['gitlab_create_file', 'gitlab_update_file', 'gitlab_create_branch'],
value: [
'gitlab_create_file',
'gitlab_update_file',
'gitlab_create_branch',
'gitlab_delete_branch',
],
},
},
// Compare from ref
{
id: 'compareFrom',
title: 'From',
type: 'short-input',
placeholder: 'Branch, tag, or commit SHA to compare from',
required: true,
condition: {
field: 'operation',
value: ['gitlab_compare_branches'],
},
},
// Compare to ref
{
id: 'compareTo',
title: 'To',
type: 'short-input',
placeholder: 'Branch, tag, or commit SHA to compare to',
required: true,
condition: {
field: 'operation',
value: ['gitlab_compare_branches'],
},
},
// Compare directly instead of using merge base
{
id: 'straight',
title: 'Compare Directly',
type: 'switch',
mode: 'advanced',
condition: {
field: 'operation',
value: ['gitlab_compare_branches'],
},
},
// Release tag name
{
id: 'tagName',
title: 'Tag Name',
type: 'short-input',
placeholder: 'Enter the Git tag for the release (e.g., v1.0.0)',
required: true,
condition: {
field: 'operation',
value: ['gitlab_create_release'],
},
},
// Release name
{
id: 'releaseName',
title: 'Release Name',
type: 'short-input',
placeholder: 'Enter release name (optional)',
condition: {
field: 'operation',
value: ['gitlab_create_release'],
},
},
// Release date
{
id: 'releasedAt',
title: 'Released At',
type: 'short-input',
placeholder: 'ISO 8601 date for an upcoming or historical release (optional)',
mode: 'advanced',
condition: {
field: 'operation',
value: ['gitlab_create_release'],
},
wandConfig: {
enabled: true,
prompt: `Generate an ISO 8601 timestamp based on the user's description of when the release happened or will happen.

Return ONLY the timestamp string - no explanations, no extra text.`,
generationType: 'timestamp',
placeholder: 'Describe when the release happened...',
},
},
// Release milestones
{
id: 'releaseMilestones',
title: 'Milestones',
type: 'short-input',
placeholder: 'Milestone titles (comma-separated, optional)',
mode: 'advanced',
condition: {
field: 'operation',
value: ['gitlab_create_release'],
},
},
// File Content
Expand Down Expand Up @@ -593,6 +707,7 @@ Return ONLY the commit message - no explanations, no extra text.`,
'gitlab_list_branches',
'gitlab_list_commits',
'gitlab_list_pipeline_jobs',
'gitlab_list_releases',
],
},
},
Expand All @@ -614,6 +729,7 @@ Return ONLY the commit message - no explanations, no extra text.`,
'gitlab_list_branches',
'gitlab_list_commits',
'gitlab_list_pipeline_jobs',
'gitlab_list_releases',
],
},
},
Expand Down Expand Up @@ -650,13 +766,17 @@ Return ONLY the commit message - no explanations, no extra text.`,
'gitlab_create_file',
'gitlab_update_file',
'gitlab_create_branch',
'gitlab_delete_branch',
'gitlab_compare_branches',
'gitlab_list_branches',
'gitlab_list_commits',
'gitlab_get_merge_request_changes',
'gitlab_approve_merge_request',
'gitlab_list_pipeline_jobs',
'gitlab_get_job_log',
'gitlab_play_job',
'gitlab_list_releases',
'gitlab_create_release',
],
config: {
tool: (params) => {
Expand Down Expand Up @@ -960,6 +1080,32 @@ Return ONLY the commit message - no explanations, no extra text.`,
page: params.page ? Number(params.page) : undefined,
}

case 'gitlab_delete_branch':
if (!params.projectId?.trim() || !params.branch?.trim()) {
throw new Error('Project ID and branch name are required.')
}
return {
...baseParams,
projectId: params.projectId.trim(),
branch: params.branch.trim(),
}

case 'gitlab_compare_branches':
if (
!params.projectId?.trim() ||
!params.compareFrom?.trim() ||
!params.compareTo?.trim()
) {
throw new Error('Project ID, from ref, and to ref are required.')
}
return {
...baseParams,
projectId: params.projectId.trim(),
from: params.compareFrom.trim(),
to: params.compareTo.trim(),
straight: params.straight || undefined,
}

case 'gitlab_list_commits':
if (!params.projectId?.trim()) {
throw new Error('Project ID is required.')
Expand Down Expand Up @@ -1026,6 +1172,37 @@ Return ONLY the commit message - no explanations, no extra text.`,
jobId: Number(params.jobId),
}

case 'gitlab_list_releases':
if (!params.projectId?.trim()) {
throw new Error('Project ID is required.')
}
return {
...baseParams,
projectId: params.projectId.trim(),
perPage: params.perPage ? Number(params.perPage) : undefined,
page: params.page ? Number(params.page) : undefined,
}

case 'gitlab_create_release':
if (!params.projectId?.trim() || !params.tagName?.trim()) {
throw new Error('Project ID and tag name are required.')
}
return {
...baseParams,
projectId: params.projectId.trim(),
tagName: params.tagName.trim(),
name: params.releaseName?.trim() || undefined,
description: params.description?.trim() || undefined,
ref: params.ref?.trim() || undefined,
releasedAt: params.releasedAt?.trim() || undefined,
milestones: params.releaseMilestones
? params.releaseMilestones
.split(',')
.map((title: string) => title.trim())
.filter(Boolean)
: undefined,
Comment thread
greptile-apps[bot] marked this conversation as resolved.
}

default:
return baseParams
}
Expand Down Expand Up @@ -1071,6 +1248,13 @@ Return ONLY the commit message - no explanations, no extra text.`,
refName: { type: 'string', description: 'Branch or tag name filter' },
scope: { type: 'string', description: 'Job scope filter' },
sha: { type: 'string', description: 'Commit SHA' },
compareFrom: { type: 'string', description: 'Branch, tag, or commit SHA to compare from' },
compareTo: { type: 'string', description: 'Branch, tag, or commit SHA to compare to' },
straight: { type: 'boolean', description: 'Compare directly instead of using the merge base' },
tagName: { type: 'string', description: 'Git tag for the release' },
releaseName: { type: 'string', description: 'Release name' },
releasedAt: { type: 'string', description: 'ISO 8601 date for the release' },
releaseMilestones: { type: 'string', description: 'Milestone titles (comma-separated)' },
},
outputs: {
// Project outputs
Expand All @@ -1082,6 +1266,7 @@ Return ONLY the commit message - no explanations, no extra text.`,
// Merge request outputs
mergeRequests: { type: 'json', description: 'List of merge requests' },
mergeRequest: { type: 'json', description: 'Merge request details' },
mergeRequestIid: { type: 'number', description: 'Merge request internal ID (IID)' },
// Pipeline outputs
pipelines: { type: 'json', description: 'List of pipelines' },
pipeline: { type: 'json', description: 'Pipeline details' },
Expand All @@ -1091,17 +1276,38 @@ Return ONLY the commit message - no explanations, no extra text.`,
tree: { type: 'json', description: 'Repository tree entries' },
content: { type: 'string', description: 'File contents (decoded)' },
fileName: { type: 'string', description: 'File name' },
filePath: { type: 'string', description: 'Path to the file in the repository' },
branch: { type: 'string', description: 'Branch the file was committed to' },
branches: { type: 'json', description: 'List of branches' },
commits: { type: 'json', description: 'List of commits' },
commit: { type: 'json', description: 'A single commit (e.g. latest commit in a comparison)' },
name: { type: 'string', description: 'Created branch name' },
protected: { type: 'boolean', description: 'Whether the branch is protected' },
size: { type: 'number', description: 'File size in bytes' },
ref: { type: 'string', description: 'The branch, tag, or commit SHA' },
blobId: { type: 'string', description: 'The blob ID' },
lastCommitId: { type: 'string', description: 'The last commit ID that modified the file' },
webUrl: { type: 'string', description: 'Web URL' },
// Merge request change outputs
changes: { type: 'json', description: 'Merge request file changes/diffs' },
changesCount: { type: 'number', description: 'Number of changed files returned' },
approvalsRequired: { type: 'number', description: 'Approvals required' },
approvalsLeft: { type: 'number', description: 'Approvals remaining' },
approvedBy: { type: 'json', description: 'List of approvers' },
// Job outputs
jobs: { type: 'json', description: 'Pipeline jobs' },
log: { type: 'string', description: 'Job log output' },
id: { type: 'number', description: 'Job ID' },
status: { type: 'string', description: 'Job status' },
// Compare outputs
diffs: { type: 'json', description: 'File diffs between two compared references' },
compareTimeout: { type: 'boolean', description: 'Whether the comparison timed out' },
compareSameRef: { type: 'boolean', description: 'Whether both compared references match' },
// Release outputs
releases: { type: 'json', description: 'List of releases' },
release: { type: 'json', description: 'Release details' },
// Pagination
total: { type: 'number', description: 'Total number of items available across all pages' },
// Success indicator
success: { type: 'boolean', description: 'Operation success status' },
},
Expand Down Expand Up @@ -1213,5 +1419,12 @@ export const GitLabBlockMeta = {
content:
'# Monitor Pipeline Status\n\nUse GitLab to keep an eye on CI pipelines.\n\n## Steps\n1. List pipelines for the project and identify the most recent runs.\n2. Get the pipeline details for any that failed to read the status and reason.\n3. If a failure looks transient, use Retry Pipeline to re-run it.\n\n## Output\nReturn a summary of recent pipeline runs (ref, status, when) and call out any failures. If a retry was triggered, include the retried pipeline ID.',
},
{
name: 'draft-release-notes',
description:
'Compare two refs, summarize the merged changes, and publish a GitLab release with generated notes.',
content:
"# Draft Release Notes\n\nUse GitLab to publish a release with notes generated from the changes since the last tag.\n\n## Steps\n1. Compare Branches between the previous release tag and the target ref to list the commits and diffs.\n2. Summarize the changes into readable release notes, grouped by feature, fix, or chore.\n3. Use Create Release with the new tag name, the generated description, and the target ref.\n\n## Output\nReturn the created release's tag name and a confirmation that the notes were published, along with the release notes text.",
},
],
} as const satisfies BlockMeta
Loading
Loading