Skip to content

Fix multi-project commit detection in GitLab import tool #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 21, 2025

The GitLab commit import tool was only detecting commits from one project when users had multiple projects across different groups. This was caused by two bugs in the project processing logic:

Root Cause

  1. Commit counter bug: The code incorrectly used the outer loop variable projectID (which always remained 0) instead of the actual project ID when storing commit counts:

    projectID := 0  // Never updated
    for _, project := range projects {
        // Process commits...
        projectCommitCounter[projectID] = commits  // BUG: Always overwrites key 0
    }
  2. Pagination inefficiency: The idAfter parameter for cursor-based pagination was never updated, causing redundant GitLab API calls.

Changes Made

  • Fixed commit tracking: Changed projectCommitCounter[projectID] to projectCommitCounter[project] to properly track each project's commits
  • Improved pagination: Added logic to update idAfter with the highest project ID from each page for efficient cursor-based pagination
  • Enhanced code clarity: Renamed confusing projectID variable to idAfter to better reflect its purpose
  • Added documentation: Included comment explaining the pagination logic

Before vs After

Before (buggy behavior):

Processing project 123 with 5 commits
Processing project 456 with 3 commits  
Processing project 789 with 8 commits
Final result: project 0: 8 commits (only last project tracked!)

After (fixed behavior):

Processing project 123 with 5 commits
Processing project 456 with 3 commits
Processing project 789 with 8 commits  
Final result:
  project 123: 5 commits
  project 456: 3 commits  
  project 789: 8 commits

Impact

Users with multiple GitLab projects across different groups will now see commits imported from all their projects, not just one. The fix also improves GitLab API efficiency by implementing proper cursor-based pagination.

Fixes #82.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: alexandear <3228886+alexandear@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Only commits under a separate group are detected Fix multi-project commit detection in GitLab import tool Jul 21, 2025
Copilot finished work on behalf of alexandear July 21, 2025 10:56
@Copilot Copilot AI requested a review from alexandear July 21, 2025 10:56
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.

Only commits under a separate group are detected
2 participants