Menu ▾ ▴

#547 Mirror GitLab projects: issues, merge requests and commits (#538)

open
nobody
None
4 hours ago
4 hours ago
Anonymous
No

Originally created by: athanclark

Part of [#538]: GitLab. This is stacked on [#546], and like it, it needs [#545] (128-character tags).

Names

Project Issue Merge request Person
gitlab.com gitlab/group/app gitlab/group/app#12 gitlab/group/app!7 gitlab/mona
Self-hosted gitlab:git.example.com/group/sub/app …#12 …!7 gitlab:git.example.com/mona
  • Merge requests are numbered apart from issues, so they are !7 in tags, titles and mentions, mr in IDs (gl:group:app:mr:7), and tagged merge request.
  • Nested groups are kept whole.

Reading GitLab

server/gitlab-source.mjs turns GitLab into the GitHub shapes the shared code reads.

Importer:

  • Items: issues and merge requests.
  • Their history: label, milestone and state events, plus system notes. The notes cover assignments, review requests, approvals, drafts, renames (with GitLab's {-…-}{+…+} marks), mentions, locks and duplicates.
  • Also: commits by branch, branches, forks, releases and milestones.
  • Token: GITLAB_TOKEN with read_api. Without one, gitlab.com keeps back events, notes and milestones; the importer leaves those out with one warning each, rather than failing.

Receiver, checked against GITLAB_WEBHOOK_TOKEN:

  • Issue Hook and Merge Request Hook: the item, plus the labels and assignees added and removed, reviewers, title, draft state, closing, reopening, merging and approval.
  • Note Hook: mentions only, never the comment's text.
  • Push Hook: commits, and branches created or deleted.
  • Release Hook: releases.

Shared reader changes:

  • Quiet branches skipped: GitLab dates each branch's last commit, so with --since branches with nothing new aren't read. On gitlab-org/cli, 531 branches cost 19 requests.
  • Retries: a request that times out or fails to connect is tried up to three times.
  • Clearer errors: they now name the host rather than "GitHub".

Tests

  • Unit: test/gitlab-source.test.mjs adds 6 tests, run against a fake API. They cover names and !n, system notes and resource events, webhooks with their changes, notes, pushes and releases, tokens, the receiver, and the importer leaving out what needs a token. All 32 source tests pass.
  • Real dry runs: read-only, without a token, against gitlab.com's gitlab-org/cli since 5 November.
  • It read 88 issues and merge requests with the right tags and IDs, and 65 commits across its active branches.
  • Notes, events and milestones need a token there, so those paths are covered by the unit tests only.
  • npm test: passes apart from contents.test.mjs, which fails locally with git ENOBUFS.

🤖 Generated with Claude Code

https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B

Related

Tickets: #538
Tickets: #545
Tickets: #546

Discussion


Log in to post a comment.