Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

License: GPL-3 https://badge.fury.io/py/git-autoshare.svg pre-commit.ci status ci status https://codecov.io/gh/acsone/git-autoshare/branch/master/graph/badge.svg

A git clone wrapper that automatically uses –reference to save disk space and download time.

Installation

To install git-autoshare in a fancy way, we recommend using pipx.

After installing pipx simply run:

$ pipx install git-autoshare

To upgrade git-autoshare at any time:

$ pipx upgrade git-autoshare

If you want git autoshare-clone to be invoked transparently in place of git clone, create the following bash script, name it git, and place it in your PATH before /usr/bin/git:

#!/bin/bash
if [ "$1" == "clone" ]
then
    shift
    /usr/bin/git autoshare-clone "$@"
else
    /usr/bin/git "$@"
fi

Usage

Configuration file

To configure it, create a file named git-autoshare/repos.yml in your user configuration directory (often ~/.config on Linux). This file must have the following structre:

host:
    repo:
        orgs:
            - organization
            - ...
        private: (True|False)
    ...:
...:

It lists all git hosts, repositories, and organizations that are subject to the sharing of git objects. Here is an example:

github.com:
    odoo:
        orgs:
            - odoo
            - OCA
    enterprise:
        orgs:
            - odoo
            - acsone
        private: True
    mis-builder:
        # shortcut to provides organizations
        - OCA
        - acsone

Note the use of the private option, used to force fetching using the ssh protocol.

It is also possible to use * as a wildcard for repository name, to have autoshare applied to all repos of some organizations:

github.com:
    "*":
        orgs:
            - odoo
            - OCA
            - acsone
        private: True

git autoshare-clone command

If configured like the example above, when you git clone the odoo or mis-builder repositories from one of these github organizations, git autoshare-clone will automatically insert the --reference option in the git clone command. For example:

$ git autoshare-clone https://github.com/odoo/odoo

will be transformed into:

$ /usr/bin/git clone --reference ~/.cache/git-autoshare/github.com/odoo https://github.com/odoo/odoo

git autoshare-submodule-add command

Same as git autoshare-clone command, you can add submodules with a reference. for example:

$ git autoshare-submodule-add https://github.com/odoo/odoo ./odoo

will be transformed into:

$ /usr/bin/git submodule add --reference ~/.cache/git-autoshare/github.com/odoo https://github.com/odoo/odoo ./odoo

git autoshare-prefetch command

The autoshare-prefetch command is mostly meant to be run in a cron job:

$ git autoshare-prefetch --quiet

will update the cache directory by fetching all repositories mentioned in repos.yml.

It can also prefetch one single repository, for example:

$ git autoshare-prefetch https://github.com/odoo/odoo.git

Environment variables

The cache directory is named git-autoshare where appdirs.user_cache_dir is (usually ~/.cache/git-autoshare/). This location can be configured with the GIT_AUTOSHARE_CACHE_DIR environment variable.

The default configuration file is named repos.yml where appdirs.user_config_dir is (usually ~/.config/git-autoshare/). This location can be configured with the GIT_AUTOSHARE_CONFIG_DIR environment variable.

By default git-autoshare invokes git as /usr/bin/git. This can be configured with the GIT_AUTOSHARE_GIT_BIN environment variable.

An environment variable is used when launching tests (to avoid configuration retrieval issue) : GIT_AUTOSHARE_MODE. Which takes only one value: ‘test’.

Credits

Author:

Contributors

  • Simone Orsi (Camptocamp)

  • Mykhailo Panarin

  • Stéphane Mangin

Maintainer:

ACSONE SA/NV

This project is maintained by ACSONE SA/NV.

Changes

1.0.0b6 (2022-02-26)

  • fix a regression where the GIT_AUTOSHARE_MODE environment variable became necessary

1.0.0b5 (2022-01-26)

  • support organization wildcards in git-autoshare-prefetch

  • support python >= 3.6 only (no code change yet, only stop testing)

1.0.0b4 (2019-07-14)

  • support ssh:// urls, remove dependency on giturlparse

1.0.0b3 (2019-07-13)

  • always prefetch cache before cloning, to make sure the cache is updated regularly

1.0.0b2 (2019-03-17)

  • add submodule-add command

  • use safe_load to parse configuration

  • allow wildcards in configuration

  • internal refactoring

1.0.0b1 (2018-01-07)

  • support for private repositories

  • better handling of remotes in prefetch

  • prefetch with –prun

1.0.0a2 (2017-10-10)

  • first packaged version

Release files for git-autoshare 1.0.0b6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-autoshare 1.0.0b6
File Size Uploaded
git-autoshare-1.0.0b6.tar.gz 23.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-autoshare 1.0.0b6
File Interpreter ABI Platform
git_autoshare-1.0.0b6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 44.5 kB

Release files / git-autoshare-1.0.0b6.tar.gz

Download URL git-autoshare-1.0.0b6.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d1dff471af5c8f30676362aa84b6d70c0aedbcc6b57a02e2c84dd4d5062bed7a
BLAKE2b-256 checksum
How to use checksums
5753237567eae8dfb8679e13dcfe62771e4ef82407e0251cc21e5aed6d0f7e5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / git_autoshare-1.0.0b6-py2.py3-none-any.whl

Download URL git_autoshare-1.0.0b6-py2.py3-none-any.whl
Size 20.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f44cd4f0a9457b5ac67f995274babae6485b46893a2f98e39935e831603bbacc
BLAKE2b-256 checksum
How to use checksums
61c2f4467b712e0249bf9b45dd6100b7497d688ddb609605dccea92f3a1c11df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
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