Skip to main content

git-component

Description

This project's goal is to add a new command to Git enabling the use of "component(s)". They resemble Git submodules and subtrees but with differentiating characteristics:

  • submodules:
    • cannot reference tags, while components can do
    • pull the whole repository, components can select which files or directories to pull
  • subtrees:
    • shall merge histories, components are ignored by git and are in read-only by default to avoid unwanted modifications

See docs/spec/ for the full specification: manifest and lock file formats, CLI behavior, and per-subcommand semantics.

Installation

Requires Python 3.8+.

From source, via pip (recommended — not yet published to the public PyPI index):

pip install .

This installs the gitcomponent package and puts a git-component executable on your PATH via the [project.scripts] entry point in pyproject.toml — which is exactly what lets Git find it and makes git component ... work as a real Git subcommand, alongside direct git-component ... invocation.

Standalone binary (no Python required on the target machine):

pip install -r requirements-dev.txt
make build   # produces dist/git-component via PyInstaller

Put the resulting git-component (git-component.exe on Windows) on your PATH.

For local development, without installing anything onto PATH:

pip install -r requirements-dev.txt
python src/main.py <subcommand> [options]

Building distributable artifacts (sdist + wheel, e.g. to hand to someone else or eventually publish):

make dist            # produces dist/*.tar.gz and dist/*.whl
make publish-check   # validates them with `twine check` (no upload)

Actually publishing (twine upload dist/*) is a deliberate, one-way action and is intentionally not automated — run it yourself when ready.

Usage

git component init
git component add <name> <repo_url> branch=<branch> --map <src>:<dest>
git component list [--all] [components...]
git component remove <components...>
git component pull [components...]
git component prune [components...]
git component status [--short]
git component resolve [components...]
git component help [command]

Full per-subcommand synopses and semantics live in docs/spec/10-commands/.

Support

Open an issue in this repository describing the problem, including the manifest/lock content involved and the exact command run.

Roadmap

v1 subcommands (per docs/spec/04-cli.md): help, init, add, remove, pull, prune, list, status, resolve. All nine are implemented, including cross-component/partial-pull priority conflict resolution, .gitignore management, and local-modification detection.

pull/resolve still shell out to git ls-remote for commit resolution on every invocation (cheap, no object transfer), but checkout now uses a local mirror cache under .git/git-components-cache/ (one per distinct repository-url, updated with git fetch rather than a fresh full clone each time) — see docs/spec/10-commands/16-pull.md.

status's output format was marked ***TBD*** in the spec; it's now decided and documented in docs/spec/10-commands/18-status.md.

order is explicitly not part of v1 (see docs/spec/10-commands/20-order.md) and is deferred to a later release.

Contributing

docs/spec/ is the source of truth for behavior — implementation changes that diverge from it should update the spec first. docs/spec/validate-error-codes.md cross-checks exit-code documentation consistency across the spec files; run it after editing exit codes.

Releasing

main is where development happens; release only ever holds commits that have been deliberately promoted from main. Tagging a commit on release triggers .gitlab-ci.yml, which runs the test suite, builds the package, then — in parallel — publishes to PyPI, creates a GitLab Release, and pushes that same commit (as main) plus the tag to the public GitHub mirror.

To cut a release:

# 1. bump the version on main
#    edit `version = "..."` in pyproject.toml, commit, push

# 2. fast-forward release to main
git checkout release
git merge --ff-only main
git push origin release

# 3. tag it (must match pyproject.toml's version, with a `v` prefix) and push the tag
git tag vX.Y.Z
git push origin vX.Y.Z

Pushing the tag is what triggers the pipeline — nothing publishes just from pushing to release.

The pipeline depends on three GitLab CI/CD variables (Settings → CI/CD → Variables), configured on the project already except where noted:

  • PYPI_PUBLISH_TOKEN (masked, protected) — a PyPI API token. For the very first release, this must be an account-scoped token, since the project won't exist on PyPI yet to scope a token to.
  • GITHUB_MIRROR_URL — the SSH URL of the public GitHub mirror (git@github.com:owner/repo.git).
  • GITHUB_DEPLOY_TOKEN (masked, protected) — an SSH deploy key (with write access) for the GitHub mirror, stored as GitLab requires: without its -----BEGIN/END----- markers and with internal line breaks stripped, since masked variables must be a single line with no whitespace. The pipeline reconstructs a normal OpenSSH private key from it.

Authors and acknowledgment

Arthur Richelet

License

Apache License 2.0

Project status

Specification complete for v1. All nine v1 subcommands are implemented and covered by an automated test suite (make test); see Roadmap for known gaps.

Download files

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

Source Distribution

git_component-0.1.1.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_component-0.1.1-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file git_component-0.1.1.tar.gz.

File metadata

  • Download URL: git_component-0.1.1.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for git_component-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c16267a99e9aa9e4f2f9cee34d7138b96f52378bdae5567731677c7d173b83b2
MD5 a303c838f6ca65bccaffd038f6a823f6
BLAKE2b-256 1e34890ba09bf18bba5672d5027178e2250cf29195175731db9cf360263096c1

See more details on using hashes here.

File details

Details for the file git_component-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: git_component-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for git_component-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 755caba7185dbdc732da00e9f2914646defb78c494c8f1720a603c4b6a257d88
MD5 2ceeb527b50483a2b654e5d7493c3e69
BLAKE2b-256 1ea148ce812bd6cd04ba9c64532fdc2c29e8a12084ffe02d0e5308f3780cf25f

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page