跳转到主要内容

一个自动使用--reference来节省时间和空间的git clone包装器。

项目描述

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

一个自动使用–reference来节省磁盘空间和下载时间的git clone包装器。

安装

要以优雅的方式安装git-autoshare,我们推荐使用pipx

安装pipx后,只需运行

$ pipx install git-autoshare

要随时升级git-autoshare

$ pipx upgrade git-autoshare

如果您想使git autoshare-clonegit clone的位置透明调用,创建以下bash脚本,命名为git,并将其放置在PATH中,在/usr/bin/git之前

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

使用方法

配置文件

要配置它,请在用户配置目录中创建一个名为 git-autoshare/repos.yml 的文件(在 Linux 上通常是 ~/.config)。此文件必须具有以下结构

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

它列出了所有要共享 git 对象的 git 主机、存储库和组织。以下是一个示例

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

请注意使用 private 选项,用于强制使用 ssh 协议进行获取。

也可以使用 * 作为存储库名称的通配符,以便自动共享某些组织的所有存储库

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

git autoshare-clone 命令

如果配置如上述示例所示,当您从这些 github 组织之一克隆 odoo 或 mis-builder 存储库时,git autoshare-clone 将自动在 git clone 命令中插入 --reference 选项。例如

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

将转换为

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

git autoshare-submodule-add 命令

git autoshare-clone 命令相同,您可以使用引用添加子模块。例如

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

将转换为

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

git autoshare-prefetch 命令

autoshare-prefetch 命令主要是在 cron 作业中运行

$ git autoshare-prefetch --quiet

将更新缓存目录,通过获取 repos.yml 中提到的所有存储库。

它还可以预取单个存储库,例如

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

环境变量

缓存目录命名为 git-autoshare,其中 appdirs.user_cache_dir 是(通常是 ~/.cache/git-autoshare/)。此位置可以通过 GIT_AUTOSHARE_CACHE_DIR 环境变量进行配置。

默认配置文件名为 repos.yml,其中 appdirs.user_config_dir 是(通常是 ~/.config/git-autoshare/)。此位置可以通过 GIT_AUTOSHARE_CONFIG_DIR 环境变量进行配置。

默认情况下,git-autosharegit 作为 /usr/bin/git 调用。这可以通过 GIT_AUTOSHARE_GIT_BIN 环境变量进行配置。

在启动测试时使用环境变量(以避免配置检索问题):GIT_AUTOSHARE_MODE。它只接受一个值:'test'。

致谢

作者

贡献者

  • Simone Orsi (Camptocamp)

  • Mykhailo Panarin

  • Stéphane Mangin

维护者

ACSONE SA/NV

此项目由 ACSONE SA/NV 维护。

变更

1.0.0b6 (2022-02-26)

  • 修复了 Git_AUTOSHARE_MODE 环境变量成为必要的回归问题

1.0.0b5 (2022-01-26)

  • 在 git-autoshare-prefetch 中支持组织通配符

  • 仅支持 python >= 3.6(尚未进行代码更改,仅停止测试)

1.0.0b4 (2019-07-14)

  • 支持 ssh:// url,删除对 giturlparse 的依赖

1.0.0b3 (2019-07-13)

  • 在克隆之前始终预取缓存,以确保定期更新缓存

1.0.0b2 (2019-03-17)

  • 添加子模块添加命令

  • 使用 safe_load 解析配置

  • 允许在配置中使用通配符

  • 内部重构

1.0.0b1 (2018-01-07)

  • 支持私有存储库

  • 改进了预取中的远程处理

  • 使用 –prun 预取

1.0.0a2 (2017-10-10)

  • 第一个打包版本

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源代码分发

git-autoshare-1.0.0b6.tar.gz (23.6 kB 查看哈希值)

上传时间: 源代码

构建分发

git_autoshare-1.0.0b6-py2.py3-none-any.whl (20.9 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下支持