Skip to content

Conversation

@ezbz
Copy link
Owner

@ezbz ezbz commented Dec 17, 2025

Issue Fixed in v2.1.1

This issue has been fixed in version 2.1.1. Here's what happened and how it was resolved:

Root Cause

The bug was introduced in PR #100 which added support for the --use-fetch flag. The original implementation incorrectly added the --mirror flag to git clone operations whenever --use-fetch was enabled. This caused all repositories cloned with --use-fetch to be created as bare repositories (mirrors) instead of normal repositories with a working tree.

The Fix

The fix separates the concerns of two different use cases:

  1. --use-fetch flag: For users who want normal repositories (with working tree) but prefer using git fetch instead of git pull for updates. This is useful when you have local branches that no longer exist on the remote.

  2. --mirror flag (new): For users who want bare mirror repositories for backup purposes. This automatically uses fetch instead of pull for updates, as mirrors should always use fetch.

Changes Made

  • Removed the automatic --mirror flag from --use-fetch clone operations
  • Added a new --mirror flag specifically for creating bare mirror repositories
  • Updated the pull method to check both use_fetch and mirror flags (mirror implies use_fetch)
  • Added comprehensive test coverage to ensure both flags work correctly together

Usage

For normal repositories with fetch updates:

gitlabber --use-fetch -t <token> -u <url> .

For bare mirror repositories (backups):

gitlabber --mirror -t <token> -u <url> .

Testing

All flag combinations have been thoroughly tested:

  • --use-fetch alone: normal repo, uses fetch
  • --mirror alone: bare repo, uses fetch
  • ✅ Both flags: bare repo (mirror takes precedence), uses fetch
  • ✅ Neither flag: normal repo, uses pull

The fix is available in v2.1.1 and has been tested to ensure backward compatibility while fixing the reported issue.


Note

Introduces --mirror for bare backups, decouples it from --use-fetch (which now only switches updates to fetch), propagates config/logic, updates docs, adds comprehensive tests, and bumps to v2.1.1.

  • CLI/Config/Core:
    • Add --mirror flag and plumb mirror through gitlabber/cli.py, GitlabberConfig, GitlabTree, and git sync APIs (GitAction, GitActionCollector, GitSyncManager, sync_tree, get_git_actions).
    • Change clone/update logic: --use-fetch no longer adds --mirror; mirror adds --mirror on clone and implies fetch on update.
    • Update pull path to use fetch when use_fetch or mirror.
  • Docs:
    • Update option help/descriptions in README.md, README.rst, docs/index.rst for --use-fetch and new --mirror.
  • Tests:
    • Add extensive tests covering use_fetch/mirror combinations and interactions; adjust helpers to mock fetch.
  • Version:
    • Bump pyproject.toml to 2.1.1.

Written by Cursor Bugbot for commit 0319f8b. This will update automatically on new commits. Configure here.

@ezbz ezbz merged commit 40e1ac2 into main Dec 17, 2025
4 checks passed
@ezbz ezbz deleted the fix/use-fetch-mirror-issue branch December 17, 2025 01:08
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.

2 participants