Skip to content

Add GitLab support via glab CLI, THE GREAT RETURN#819

Open
nicolaric wants to merge 13 commits intodlvhdr:mainfrom
nicolaric:fix/gitlab-glab-auth-state
Open

Add GitLab support via glab CLI, THE GREAT RETURN#819
nicolaric wants to merge 13 commits intodlvhdr:mainfrom
nicolaric:fix/gitlab-glab-auth-state

Conversation

@nicolaric
Copy link
Copy Markdown

Summary

This fixes the remaining issues of #736. The original author asked me to take it over but is not responding anymore.

How Did You Test this Change?

Locally and thoroughly

Images/Videos

hjanuschka and others added 13 commits February 12, 2026 16:29
Features:
- Add --gitlab <hostname> flag to enable GitLab mode
- Add provider abstraction layer (provider package)
- GitLab provider uses glab CLI for API calls
- Support MR (Merge Request) terminology in GitLab mode
- Support GitLab-specific query syntax (repo:, author:, assignee:, reviewer:, label:)
- Tasks (merge, close, reopen, etc.) use glab mr commands in GitLab mode

Usage:
  ./gh-dash --gitlab gitlab.example.com --config ./gitlab-config.yml

Configuration:
  In GitLab mode, use 'repo:GROUP/PROJECT' in filters to specify the project.

Prerequisites:
  - glab must be installed and configured with: glab auth login --hostname <your-gitlab-host>
- Fetch and cache label colors from GitLab API for each project
- Use cached colors when displaying labels in MRs and Issues
- Fall back to default gray color (6e7681) when no color is available
- Handle both GitHub (no #) and GitLab (with #) color formats
- Fetch MR commits via GitLab API (projects/:id/merge_requests/:iid/commits)
- Fetch MR changed files via GitLab API (projects/:id/merge_requests/:iid/changes)
- Parse diff to count additions/deletions per file
- Show file change count in MR overview (from changes_count field)
- Commits tab now shows commit history with author and date
- Files Changed tab now shows list of modified files with +/- stats
Updated all commands to use glab instead of gh when in GitLab mode:

PR/MR operations:
- diff: glab mr diff
- checkout: glab mr checkout
- comment: glab mr note
- approve: glab mr approve
- assign/unassign: glab mr update --assignee/--unassign
- watch checks: glab ci status --live

Issue operations:
- close: glab issue close
- reopen: glab issue reopen
- comment: glab issue note
- assign/unassign: glab issue update --assignee/--unassign
- label: glab issue update --label/--unlabel
- Add Files field to EnrichedPullRequestData for GitLab
- Convert provider ChangedFiles to data ChangedFiles
- Update Files Changed tab to use enriched data when available
- Update overview to show correct files/commits count from enriched data
- Add GLAB_PAGER env var for glab mr diff command
- Use GitLab API endpoint (projects/:id/merge_requests/:iid/notes) instead of non-existent 'glab mr note list' command
- Filter out system-generated notes (commits, description changes, etc.)
- Update comment count to reflect actual user comments
Issue comments:
- Add FetchIssueComments to Provider interface
- Implement GitLab API call (projects/:id/issues/:iid/notes)
- Filter out system-generated notes
- Add enrichment mechanism to fetch comments when viewing an issue
- Handle IssueCommentsMsg in UI to update sidebar

Pagination:
- Add --page flag support to FetchPullRequests and FetchIssues
- Use EndCursor as page number (stored as string)
- Return next page number in EndCursor for subsequent fetches
The syncSidebar() function returns a tea.Cmd that fetches issue comments
for GitLab, but this command was not being executed in several places:

- onViewedRowChanged: was overwriting cmd with PR enrich only
- TogglePreview: was not using the returned cmd at all
- Text input handlers: were not batching the sync cmd

Fixed by:
- Using tea.Batch to combine syncSidebar cmd with other cmds
- Simplified EnrichIssueComments condition (always fetch if no nodes)
The bug was that after SetIssueComments updated the issue with fetched
comments, syncSidebar() was called which re-fetched the row data from
the section (without comments) and overwrote the updated data.

Fix: Just update the sidebar content directly instead of calling
syncSidebar() after setting comments.

Also added debug logging to FetchIssueComments for troubleshooting.
- Add getRepoFlag() helper to return '--repo' for GitLab, '-R' for GitHub
- Fix PRReady to use 'glab mr update --ready' for GitLab
- Fix UpdatePR to use 'glab mr rebase' for GitLab (instead of update-branch)
- Fix MergePR and CreatePR to use correct repo flag
- Update task messages to use MR label for GitLab
- Remove debug logging from FetchIssueComments
- Fetch pipeline jobs from GitLab API when enriching MR data
- Display pipeline jobs in the Checks tab with status icons
- Support both 'pipeline' and 'head_pipeline' fields from GitLab API
- Add PipelineJob struct to provider and data layers
- Calculate check stats from GitLab jobs for overview display
@nicolaric nicolaric changed the title Fix/gitlab glab auth state Add GitLab support via glab CLI, THE GREAT RETURN Mar 28, 2026
@dlvhdr
Copy link
Copy Markdown
Owner

dlvhdr commented Mar 28, 2026

I think the first step in merging something like this is breaking it apart into smaller prs. I imagine making the code forge agnostic is one part. Then glab is another. Ideally it can be split even further.

@nicolaric
Copy link
Copy Markdown
Author

i added this split:
#821

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.

3 participants