Giter Club home page Giter Club logo

git-autoshare's Introduction

git-autoshare

License: GPL-3 https://travis-ci.org/acsone/git-autoshare.svg?branch=master

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

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

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

Note

In this configuration, git-autoshare-prefetch without arguments will not fetch any wildcard repo. This could be improved in the future to refetch repos that are already present in cache.

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

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

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

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.

Author:

Contributors

Maintainer:

ACSONE SA/NV

This project is maintained by ACSONE SA/NV.

git-autoshare's People

Contributors

sbidoul avatar simahawk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.