Fetch all comments/discussions from the current GitLab Merge Request.
- Determine the current branch:
git branch --show-current - 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) - URL-encode the project path (replace
/with%2F) - 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"
- 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"
- 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
- Summarize: total comments, unresolved count, and key action items
GITLAB_API_TOKENenvironment variable must be set with a GitLab personal access token (scope:read_api)- If using a self-hosted GitLab instance, replace
gitlab.comwith your instance URL