Skip to main content

A git clone wrapper that automatically uses --reference to save time and space.

Project description

License: GPL-3 https://badge.fury.io/py/git-autoshare.svg https://travis-ci.org/acsone/git-autoshare.svg?branch=master 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.

Credits

Author:

Contributors

Maintainer:

ACSONE SA/NV

This project is maintained by ACSONE SA/NV.

Changes

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

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

git-autoshare-1.0.0b4.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

git_autoshare-1.0.0b4-py2.py3-none-any.whl (20.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file git-autoshare-1.0.0b4.tar.gz.

File metadata

  • Download URL: git-autoshare-1.0.0b4.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for git-autoshare-1.0.0b4.tar.gz
Algorithm Hash digest
SHA256 102c605130b05bdce8e6a02e628bebd8d69c098d00e5b7ffdf5d60469bb69dd1
MD5 f60cac324da05889c556f852c6a72d65
BLAKE2b-256 706574a37bc6312e55f414fdfae624d256d221c624b92115d0056e50596c7924

See more details on using hashes here.

File details

Details for the file git_autoshare-1.0.0b4-py2.py3-none-any.whl.

File metadata

  • Download URL: git_autoshare-1.0.0b4-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7

File hashes

Hashes for git_autoshare-1.0.0b4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d5e5417aee29ab29e5df34c317ba377074de73de92248c87380c458514d44ce3
MD5 c18b2115f86fe83f94b64f8ec90bd619
BLAKE2b-256 773ee19230c45f528c7b62e0cdb5175f782e57aea0087eb97ffc35b311fde098

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