A GitHub CLI extension for scanning GitLab instances and generating comprehensive repository statistics reports. This tool provides GitLab equivalent functionality to GitHub's repository inventory tools, generating CSV output compatible with GitHub analysis workflows.
- π Comprehensive Scanning: Scan GitLab.com or self-hosted GitLab instances
- π Detailed Statistics: Collect repository metadata, collaboration metrics, and activity data
- π¬ Comment Tracking: Counts comments on merge requests, issues, and commits
- π Review Metrics: Tracks merge request reviews and approvals
- π¦ LFS Support: Reports Git LFS storage usage per project
- π³ Wiki Detection: Verifies actual wiki content (not just enabled status)
- π― Direct REST API: Uses GitLab REST API directly for full transparency and control
- π Real-time Progress: Enhanced logging shows detailed progress for each project
- π Secure: Uses GitLab personal access tokens for authentication
- π¦ Zero External Dependencies: Built using only Go standard library for API calls
- Go 1.21 or later
- GitLab personal access token with appropriate permissions
git clone https://github.com/mona-actions/gh-gitlab-stats.git
cd gh-gitlab-stats
go build -o gh-gitlab-stats .If you're using this as a GitHub CLI extension:
# Install as a GitHub CLI extension (if publishing to GitHub)
gh extension install mona-actions/gh-gitlab-stats- Go to GitLab β Settings β Access Tokens
- Create a token with the following scopes:
read_apiread_repository
# Scan GitLab.com (all accessible projects) - saves CSV to timestamped file
./gh-gitlab-stats --hostname gitlab.com --token YOUR_GITLAB_TOKEN
# Scan self-hosted GitLab
./gh-gitlab-stats --hostname gitlab.company.com --token YOUR_GITLAB_TOKEN
# Display results as table in console
./gh-gitlab-stats --hostname gitlab.com --token YOUR_GITLAB_TOKEN --output Table# Show help
./gh-gitlab-stats --help
# Scan with debug output (detailed logging)
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --debug
# Use table output format (display in console)
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --output Table
# Use CSV output format (default - saves to timestamped file)
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --output CSV| Flag | Description | Default |
|---|---|---|
--token, -t |
GitLab access token (required) | |
--hostname, -H |
GitLab hostname (without https:// prefix) | gitlab.com |
--output, -O |
Output format: CSV (timestamped file) or Table (console) |
CSV |
--debug, -d |
Enable debug logging with detailed progress | false |
--namespace, -n |
GitLab namespace/group to analyze (e.g., "mygroup/subgroup") | |
--input, -i |
File with list of namespaces (one per line) | |
--repo-list |
File with list of repositories in "namespace/project" format |
You can set the GitLab token via environment variable:
export GITLAB_TOKEN="your-token-here"
./gh-gitlab-stats --hostname gitlab.comThe tool generates CSV output with comprehensive GitLab project statistics:
| Column | Type | Description | Data Source |
|---|---|---|---|
Namespace |
String | Full namespace path (e.g., "group/subgroup") | API: path_with_namespace |
Project |
String | Project name | API: name |
Is_Empty |
Boolean | Whether repository is empty | API: empty_repo |
isFork |
Boolean | Whether project is a fork | API: forked_from_project |
isArchive |
Boolean | Whether project is archived | API: archived |
Project_Size(mb) |
Number | Repository size in megabytes | API: statistics.repository_size |
LFS_Size(mb) |
Number | Git LFS storage size in megabytes | API: statistics.lfs_objects_size |
Collaborator_Count |
Integer | Number of project members | API: /members/all endpoint |
Protected_Branch_Count |
Integer | Number of protected branches (estimated) | Computed from branch count |
MR_Review_Count |
Integer | Number of merge request reviews/approvals | API: MR upvotes + approved_by |
Milestone_Count |
Integer | Number of milestones | API: /milestones endpoint |
Issue_Count |
Integer | Number of issues (open) | API: open_issues_count |
MR_Count |
Integer | Number of merge requests (all states) | API: /merge_requests endpoint |
MR_Review_Comment_Count |
Integer | Total comments on all merge requests | API: MR user_notes_count sum |
Commit_Count |
Integer | Total number of commits | API: statistics.commit_count |
Issue_Comment_Count |
Integer | Total comments on all issues | API: Issue user_notes_count sum |
Release_Count |
Integer | Number of releases | API: /releases endpoint |
Branch_Count |
Integer | Number of branches | API: /repository/branches endpoint |
Tag_Count |
Integer | Number of tags | API: /repository/tags endpoint |
Has_Wiki |
Boolean | Whether wiki has actual content | API: /wikis endpoint (verified) |
Full_URL |
String | Full web URL to the project | API: web_url |
Created |
Timestamp | Project creation date/time (RFC3339) | API: created_at |
Last_Push |
Timestamp | Last push/activity date/time (RFC3339) | API: last_activity_at |
Last_Update |
Timestamp | Last update date/time (RFC3339) | API: last_activity_at |
- String: Text values (UTF-8 encoded)
- Boolean:
trueorfalse - Integer: Whole numbers (0, 1, 2, ...)
- Number: Decimal numbers (0.0, 25.5, 1024.8)
- Timestamp: ISO 8601 / RFC3339 format (e.g.,
2023-10-10T15:30:00Z)
Namespace,Project,Is_Empty,isFork,isArchive,Project_Size(mb),LFS_Size(mb),Collaborator_Count,Protected_Branch_Count,MR_Review_Count,Milestone_Count,Issue_Count,MR_Count,MR_Review_Comment_Count,Commit_Count,Issue_Comment_Count,Release_Count,Branch_Count,Tag_Count,Has_Wiki,Full_URL,Created,Last_Push,Last_Update
mygroup,awesome-project,false,false,false,250,1024,8,2,12,3,23,15,45,150,128,2,15,8,true,https://gitlab.com/mygroup/awesome-project,2023-01-15T10:00:00Z,2023-10-10T15:30:00Z,2023-10-10T15:30:00Z
mygroup/subgroup,another-project,false,true,false,150,0,5,1,5,1,8,5,22,85,35,1,8,3,false,https://gitlab.com/mygroup/subgroup/another-project,2023-03-20T14:22:00Z,2023-10-09T08:15:00Z,2023-10-09T08:15:00Z
# Scan all accessible projects on GitLab.com
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN
# Scan with detailed debug logging
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --debug
# Scan self-hosted GitLab instance
./gh-gitlab-stats \
--hostname gitlab.company.com \
--token $GITLAB_TOKEN
# Scan specific namespace/group
./gh-gitlab-stats \
--hostname gitlab.com \
--token $GITLAB_TOKEN \
--namespace mygroup/subgroup# CSV output (default) - saved to timestamped file like gitlab-stats-2025-10-10-14-24-27.csv
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --output CSV
# Table output (console display) - prints formatted table to stdout
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --output TableNormal Mode (Compact Progress)
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKENπ Discovering projects...
β Found 25 projects to scan
[5/25] Scanning projects... Current: group/subgroup | my-repository
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SCAN COMPLETE
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Total projects found: 25
Successfully processed: 25
Errors encountered: 0
Duration: 2m15s
Average time per project: 5.4s
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Debug Mode (Detailed Progress)
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --debugπ Discovering projects...
β Found 25 projects to scan
Using 5 parallel workers for scanning
β Processing: group/subgroup/project (ID: 12345)
Fetching detailed statistics...
β Retrieved: branches(15), tags(8), members(5), issues(23), MRs(12)
β Reviews: MR Reviews(12) | Commits(150)
β Comments: MR(45), Issue(128), Commit(0)
[5/25] β Scanned: group/subgroup/project
Size: 250 MB | LFS: 1024 MB | Commits: 150 | Issues: 23 | MRs: 12 | Branches: 15 | Tags: 8
The tool makes efficient API calls to minimize rate limiting:
- Pagination: Fetches data in pages of 100 items
- Header Counts: Uses
X-Totalheaders when available - Parallel Processing: Scans up to 5 projects simultaneously
- Sampling: For large projects (>1000 MRs/issues), limits to first 1000
Authentication Error
Error: GitLab token is required
- Ensure you provide a valid GitLab personal access token
- Check token has required scopes:
read_api,read_repository
Connection Issues
Error: failed to connect to GitLab
- Verify the hostname is correct (without
https://prefix) - Check network connectivity to the GitLab instance
- Ensure the GitLab instance is accessible
# Enable debug output to see detailed progress
./gh-gitlab-stats --hostname gitlab.com --token $GITLAB_TOKEN --debugThe tool follows clean architecture principles with direct REST API integration:
βββ cmd/ # CLI commands (Cobra)
β βββ root.go # Root command with scan logic
βββ internal/
β βββ api/ # GitLab REST API client
β β βββ rest_client.go # Direct HTTP/REST implementation
β β βββ types.go # API response types
β βββ models/ # Domain models
β β βββ types.go # RepositoryStats, ScanOptions
β βββ services/ # Business logic
β β βββ scanner.go # Project scanning service
β βββ ui/ # Output formatting
β βββ formatter.go # CSV/JSON/YAML formatters
βββ main.go # Entry point
- REST Client: Direct HTTP calls to GitLab REST API v4 using Go standard library
- Fetches project metadata, statistics, and counts
- Implements efficient pagination and header-based counting
- Verifies wiki content, counts comments, and tracks reviews
- Scanner Service: Orchestrates project discovery and statistics collection
- Parallel processing with worker pools (5 concurrent workers)
- Real-time progress reporting
- Error handling and recovery
- Formatters: Convert statistics to CSV or Table output
- Progress Reporters: Console and quiet modes for different use cases
- Zero Dependencies: Uses only Go standard library for API calls (no external GitLab SDK)
- Discovery: Fetch all accessible projects via
/projectsendpoint - Parallel Scanning: Process projects using worker pool
- Per Project:
- Fetch detailed statistics with
statistics=true - Count branches, tags, members, milestones, releases
- Sum comments from MRs and issues
- Count MR reviews/approvals
- Verify wiki content
- Fetch detailed statistics with
- Output: Format and write results to CSV/Table
git clone https://github.com/mona-actions/gh-gitlab-stats.git
cd gh-gitlab-stats
go mod tidy
go build -o gh-gitlab-stats .This project is licensed under the MIT License. See LICENSE file for details.