Skip to content

Instantly share code, notes, and snippets.

@arutkayb
Created February 20, 2026 15:49
Show Gist options
  • Select an option

  • Save arutkayb/d842121ed0e76b61f835ff3983b4622e to your computer and use it in GitHub Desktop.

Select an option

Save arutkayb/d842121ed0e76b61f835ff3983b4622e to your computer and use it in GitHub Desktop.

MR Comments

Fetch all comments/discussions from the current GitLab Merge Request.

Instructions

  1. Determine the current branch: git branch --show-current
  2. Get the GitLab project path from the git remote: git remote get-url origin, then extract the project path (remove .git suffix and host prefix)
  3. URL-encode the project path (replace / with %2F)
  4. Find the open MR for the current branch using:
   curl --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" "https://gitlab.com/api/v4/projects/<encoded_project_path>/merge_requests?source_branch=<current_branch>&state=opened"
  1. Fetch all discussions (comments) for that MR:
   curl --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" "https://gitlab.com/api/v4/projects/<encoded_project_path>/merge_requests/<mr_iid>/discussions"
  1. Parse and present the comments in a clear format:
    • Show author, date, and body for each comment
    • Group threaded replies together
    • Indicate which comments are resolved vs unresolved
    • Show the file path and line number for inline comments
  2. Summarize: total comments, unresolved count, and key action items

Requirements

  • GITLAB_API_TOKEN environment variable must be set with a GitLab personal access token (scope: read_api)
  • If using a self-hosted GitLab instance, replace gitlab.com with your instance URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment