Multi Repository Management Tool
Project description
Multi Repository Management Tool
AnyRepo is a lightweight tool for creating and managing workspaces consisting of several interdependent git
repositories. Starting from a main repository, AnyRepo discovers dependencies specified in a manifest file, fetching any specified required repositories and assembling them into a single workspace.
👉 You can read more about the used nomenclature in the documentation.
📦 Installation
AnyRepo is written in Python and - as usual - installing it is pretty easy:
pip install anyrepo
And that's it! Ideally, if your project also uses Python, we recommend adding AnyRepo as a dependency to it as well, so that you can track the exact version of it together with your other dependencies. For example, if you use poetry
, add it by running
# Add AnyRepo as development dependency:
poetry add --group dev anyrepo
📔 Usage
AnyRepo comes with a command line client called anyrepo
- this is what you will be using most of the time.
Let's assume we have a project called myapp
, which requires a library mylib
that is maintained in another git
repository. In order to use this project with AnyRepo, myapp
needs to provide a so called manifest. An AnyRepo manifest is a simple TOML file - by default called anyrepo.toml
in the project's root folder - which defines the dependencies a project has as well as some other meta information. A minimal manifest for our project could look like this:
[[dependencies]]
name = "mylib"
url = "git@github.com:example/mylib.git"
revision = "v2.3.4"
If myapp
and mylib
are stored on the same server (side-by-side), than the manifest can even be simpler:
[[dependencies]]
name = "mylib"
revision = "v2.3.4"
The project will be searched via a relative path (which is either ../mylib
or ../mylib.git
depending on the main repository's URL). Relative paths are in general useful as they allow to use the same protocol for the main repository as well as any of its dependencies.
To build a workspace from a project prepared like that, simply clone it via anyrepo
:
cd $HOME/Projects
mkdir my_app_workspace
cd my_app_workspace
anyrepo clone --update git@github.com:example/myapp.git
👉 Without the --update
option, only the main repository will be fetched.
The above will clone the app repository and also the library side-by-side:
ls -a
# Should print something like
# . .. .anyrepo myapp mylib
As you can see, besides the two repositories we wanted, there is also a hidden .anyrepo
folder where the tool stores the needed configuration data.
Sometimes there are use cases where using anyrepo clone
cannot be used. For example, when a CI/CD system creates the initial clone of the main repository, you may need a way to fetch the remaining projects. This can be done by simply running the following within the main project:
anyrepo init --update
👉 As with anyrepo clone
, without the --update
, no dependencies will be fetched.
Another important use case is keeping a workspace up-to-date. Lets say you pull in an update in the main repository, which in turn might cause changes in the manifest to be pulled in as well. Updating the existing workspace is as simple as
# Update the workspace (main and all dependent repositories):
anyrepo update
# Alternatively, run `git rebase` instead of `git pull` in dependencies:
anyrepo update --rebase
Cheat-Sheet
Command | Description |
---|---|
anyrepo clone URL |
Clone git repository from URL as main repository and initialize AnyRepo workspace |
anyrepo init |
Initialize AnyRepo workspace. Use existing git clone as main repository |
anyrepo manifest create |
Create well documented, empty manifest |
anyrepo update |
Pull latest changes on main repository and all dependent repositories (and clone them if needed) |
anyrepo update --rebase |
Same as above, but fetch and rebase instead |
anyrepo status |
Run git status on all repositories (displayed paths include the actual clone path) |
anyrepo add FILES |
Run git add FILE on FILES in the corresponding repositories |
anyrepo reset FILES |
Run git reset FILE on FILES in the corresponding repositories. Undo git add |
anyrepo commit FILES -m MESSAGE |
Run git commit FILE on FILES in the corresponding repositories |
anyrepo checkout FILES |
Run git checkout FILE on FILES in the corresponding repositories |
anyrepo checkout |
Checkout git revision specified as specified in the manifests |
anyrepo push |
Run git push on all repositories |
anyrepo fetch |
Run git fetch on all repositories |
anyrepo rebase |
Run git rebase on all repositories |
anyrepo pull |
Run git pull on all repositories |
anyrepo diff |
Run git diff on all repositories |
anyrepo git CMD |
Run git CMD on all repositories |
anyrepo foreach CMD |
Run CMD on all repositories |
anyrepo manifest freeze |
Print The Resolved Manifest With SHAs For All Project Revisions |
anyrepo manifest resolve |
Print The Manifest With All Imports Resolved |
🐍 Python API
AnyRepo is written in Python. Besides the anyrepo
command line tool, there is also an API which you can use to further automate workspace creation and maintenance. If you are interested, have a look into the API documentation.
🤝 Alternatives
Before writing AnyRepo, we investigates several other existing tools in the hope they would fulfil out needs. In particular, we looked into the following tools and methodologies which are widely used to organize large projects:
git submodules
.- Google's repo tool.
- The
west
tool developed in the scope of Zephyr. - Leaving the pure
git
domain, one can also use a package manager likeconan
. - And lastly, there are also approaches to still pack everything into a large so called monorepo.
Unfortunately, none of the tools we tested really satisfied us. But hey, as we are developers - why not starting our own tool for the purpose?
And that's what we did - AnyRepo is a our tool for managing a large workspace consisting of several smaller git
projects. Here is how it compares to the other tools we evaluated:
git submodules |
repo |
west |
Monorepos | AnyRepo | |
---|---|---|---|---|---|
Reusable Components | ✅ | ✅ | ✅ | ➖ | ✅ |
Ease of Use | ➖ | ✅ | ✅ | ✅ | ✅ |
Editable Components | ➖ | ✅ | ➖ | ✅ | ✅ |
Freezing Configurations | ✅ | ✅ | ✅ | ✅ | ✅ |
Transitive Dependencies | ➖ | ➖ | ✅ | ➖ | ✅ |
Relative Dependency Paths | ✅ | ✅ | ➖ | ➖ | ✅ |
👉 Please note that our view on the various features might be biased. As we did, always look at all the options available to you before deciding for one tool or the other. While the other tools in comparison did not model what we needed for our workflow, they might just be what you are looking for.
If you want to learn more, have a look into the documentation.
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
Built Distribution
File details
Details for the file anyrepo-0.5.0.tar.gz
.
File metadata
- Download URL: anyrepo-0.5.0.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.17.12-100.fc34.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2dba0826c36a32ecb35a1e870775103fdbeedacae34aae6d3342cd21a3020b7 |
|
MD5 | d469f6c73043bbadcb3e79e096d7cd92 |
|
BLAKE2b-256 | 67c18518c3645b2eea8e300d793f00ffd4b14af59829a4cd7ee421b467182c52 |
File details
Details for the file anyrepo-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: anyrepo-0.5.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.17.12-100.fc34.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62879d5887d2c2091b1fe57ab18ca8baba1af0a9ad92fe252b62cdbf9df8f316 |
|
MD5 | 3d8b824f1123754c5227afa2f68ca87f |
|
BLAKE2b-256 | 08675565926954affc9b6db12cd6b519090b063ae61f1c398caa6ba5d27aa1a6 |