Skip to content

Conversation

@hjanuschka
Copy link

Summary

This PR adds support for GitLab instances, allowing users to use gh-dash with their GitLab servers via the glab CLI.

Features

  • New --gitlab <hostname> flag: Enables GitLab mode and specifies which GitLab instance to connect to
  • Provider abstraction layer: New internal/provider package that abstracts the differences between GitHub and GitLab APIs
  • GitLab provider implementation: Uses the glab CLI for all API interactions
  • MR terminology: Shows "MR/MRs" (Merge Requests) instead of "PR/PRs" when in GitLab mode
  • GitLab-specific query syntax: Supports repo:, author:, assignee:, reviewer:, label: filters
  • Label colors: Fetches and caches label colors from GitLab for proper display
  • Task commands: All actions (merge, close, reopen, etc.) use glab mr commands in GitLab mode

Usage

# Ensure glab is installed and configured
glab auth login --hostname gitlab.example.com

# Run gh-dash with GitLab
gh-dash --gitlab gitlab.example.com --config ./my-gitlab-config.yml

Configuration Example

# In GitLab mode, use 'repo:GROUP/PROJECT' in filters
prSections:
  - title: My Merge Requests
    filters: repo:mygroup/myproject author:@me
  - title: Needs My Review
    filters: repo:mygroup/myproject reviewer:@me

issuesSections:
  - title: My Issues
    filters: repo:mygroup/myproject author:@me
  - title: Assigned to Me
    filters: repo:mygroup/myproject assignee:@me

Prerequisites

  • glab CLI must be installed (installation guide)
  • glab must be authenticated with the target GitLab instance

Technical Details

  • No changes to existing GitHub functionality - all changes are additive
  • The provider pattern allows for easy addition of other Git hosting platforms in the future
  • Label colors are cached per-project to minimize API calls

Screenshots

Works the same as GitHub mode, but connects to GitLab instances

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.
@hjanuschka hjanuschka changed the title Add GitLab support via glab CLI WIP: Add GitLab support via glab CLI Jan 7, 2026
- 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
@hjanuschka hjanuschka changed the title WIP: Add GitLab support via glab CLI Add GitLab support via glab CLI Jan 7, 2026
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.

1 participant