Skip to main content

Repository Collection Mirror

Project description

Recomi -- The Repository Collection Mirror

Recomi is a batch-orientated tool for keeping local collections of git repositories mirroring their remote upstream counterparts.

Each "collection" is a directory that contains repositories. Normally the repositories would be --mirror ones, but this works with ordinary clones too.

At its simplest this tool is little more than git fetch in a for loop. But what it also offers is a structured way to find out if there are any new repositories upstream and then automatically clone them.

Usage

$ recomi fetch /path/to/collection1 /path/to/collection2...
$ recomi gc /path/to/collection1 /path/to/collection2...
$ recomi clone /path/to/collection1 /path/to/collection2...
$ recomi mirror /path/to/collection1 /path/to/collection2...

The mirror command is equivalent to running fetch then gc then clone for each collection.

Installation

To install the last stable version into your current virtualenv run:

$ pip install recomi

Alternatively you can get the current development version with:

$ pip install git+https://github.com/pscl4rke/recomi.git

Configuration

The fetch and gc commands need no configuration.

For clone you need to create a config file inside each collection with the name recomi.ini. The bare minimum contents is:

[clone]
list = shell-command argument1 argument2...
url = git://example.com/example/{name}.git

Use list to define a shell command that will communicate with the upstream source and return a list of repositories (one per line).

Use url to turn each listed repository into a clonable SSH/URL pattern. It will replace {path} with the full path that list returned, and will replace {name} with just the name part.

Also use type set to either working, mirror, mirror-ff or bare to describe what type of clone to make. It is optional and defaults to mirror. Using mirror-ff is experimental: it rewrites the fetch ref from +refs/*:refs/* to refs/*:refs/* to prevent forced updates and ensure history is preserved.

By default recomi will warn you (on stderr) when it clones a new repository. Set warn to false to clone without a warning.

If the output of list contains paths (e.g. foo/bar.git) Recomi's default behaviour is to mimic git clone and it will only use the basename (resulting in bar or bar.git getting cloned). Setting onlybase to false will include the path prefix in the cloned destination, with slashes converted to double underscores (so foo__bar or foo__bar.git will be locally created). This is useful for hosting forges that file repositories under username or organisation subsections, as the subsections might have duplicate names.

Another example:

[clone]
list = ssh mygithost list | grep -v bigrepo
url = mygithost:{name}.git
type = working

Usage with Cron

Note that recomi distinguishes between routine output, which is sent to stdout, and errors/warnings, which are sent to stderr. Thus you can use a shell pipeline or redirection to send stdout to a log somewhere while letting cron collect up stderr and send it as an email:

8 4 * * * recomi fetch /path/to/dir | logger -t recomi-dir

Limitations

  • Recomi is deliberately only interested in pulling from upstream repositories in an unattended manner. If you would like interactive tooling to manage both pulling and pushing repositories then look into whether myrepos or gitbatch might be better suited to you.
  • Recomi currently doesn't handle submodules.
  • Recomi currently doesn't manage hook scripts.
  • Recomi may be vulnerable to forced updates unless mirror-ff is used.
  • Recomi is generally case-sensitive. Many collection hosts will consider foobar and FooBar the same and allow for smooth renaming, but Recomi will detect this as a new repository and clone from scratch.

Debugging

By running make dev you can create a development virtualenv, and can run ./dev/venv/bin/recomi to test out the program.

Running make test will run the test suite within the development virtualenv.

By setting the environment variable RECOMI_DRY_RUN=True you can see which git commands would have been run without actually running them.

Licence

This software is licensed under the GPLv3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

recomi-1.1.0.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file recomi-1.1.0.tar.gz.

File metadata

  • Download URL: recomi-1.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for recomi-1.1.0.tar.gz
Algorithm Hash digest
SHA256 23a128bb6722fc8c04e3007ec527c44e67d2cb06391eefc77c30d05d01829264
MD5 db92eb00236e35962355683b0c4115c6
BLAKE2b-256 b1e8528447f484ca1de37f140fc21f7b7558d7fdb665a44b08588c958bde2301

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page