1 个不稳定版本
0.1.0 | 2023年5月26日 |
---|
#1655 在 开发工具
21KB
209 行
GitLab Clone Group
此工具允许您下载 GitLab 组中的所有仓库。它使用 git clone
和 git fetch
命令下载仓库。
示例用法
cargo run -- 9655804 --download-folder ~/Projects/GitLab
# or
gitlab-clone-group 30 --gitlab-url gitlab.example.com --download-folder ~/Projects/GitLab --exclude-group-names "old-group"
使用 --gitlab-url
,此工具也可以在企业环境中使用。如果 GitLab API 不可从您的系统获取,您可以通过其他方式下载它,并使用 --project-list-from-file
选项。
如果没有提供 --project-list-from-file
,则需要 GitLab API 密钥。
克隆仓库
此工具将使用系统的 git clone
命令下载仓库,并使用 ssh。例如
git clone [email protected]:df-modding-tools/df-raw-language-server.git ~/Projects/GitLab/df-modding-tools__df-raw-language-server`
默认情况下,子组中的所有 /
将被替换为 __
(两个下划线)。这样做是为了使所有仓库都嵌套在单个文件夹中。
每次 clone
后,应用程序会稍微休眠一下,以防止超负荷/DoS GitLab 服务器。
更新仓库
如果仓库已经存在,它将运行 git fetch
以下载所有新更改。这将不会覆盖现有的文件或具有未提交更改的项目。
您可以使用 --checkout-default-branch
命令来在每个仓库中执行 git checkout
。它将检出在 GitLab 中设置的默认分支(通常是 master
或 main
)。
命令选项
> gitlab-clone-group --help
Usage: gitlab-clone-group [OPTIONS] <GITLAB_GROUP_ID>
Arguments:
<GITLAB_GROUP_ID> The ID of the GitLab group. This is usually a number
Options:
--gitlab-url <GITLAB_URL>
The main URL where the gitlab instance can be found. Default: `gitlab.com`
--download-folder <FOLDER>
The folder the GitLab instance will be cloned to. Default is the current working directory
--checkout-default-branch
If set to `true` it will try to check out the default branch again. This will not succeed when local changes are made that are not committed
--exclude-group-names <EXCLUDE_GROUP_NAMES>
List of group names to not download. Group name must be an exact match
--project-list-from-file <PROJECT_LIST_FROM_FILE>
JSON File where the list of projects will be found. If this option is present it will not use the GitLab API to download the list of projects. This expected format is the same json format as it would have received from the GitLab API
-h, --help
Print help
-V, --version
Print version
示例命令使用
gitlab-clone-group 9655804 --download-folder ./test
输出(终端输出有颜色)
To download the list of projects we need a GitLab API Key.
You can create a personal access token here:
https://gitlab.com/-/profile/personal_access_tokens?name=Download+GitLab+Projects&scopes=read_api
Please enter your API Key:
INFO [gitlab_clone_group] Downloading page 1 from GitLab API.
INFO [gitlab_clone_group] Downloading page 2 from GitLab API.
INFO [gitlab_clone_group] Found in GitLab: 5
INFO [gitlab_clone_group] After filtering: 5
Projects: [
"df-modding-tools/df-test-mod",
"df-modding-tools/df-raw-language-server",
"df-modding-tools/df-raw-collection",
"df-modding-tools/df-raw-syntax",
"df-modding-tools/df-syntax-highlighting",
]
Going to downloading the 5 repo's listed above. Press any key to continue. Press `ctrl+c` (`^c`) to quit.
INFO [gitlab_clone_group] Project 0/5 DF Test Mod
INFO [gitlab_clone_group] Cloning repo
Cloning into 'df-modding-tools__df-test-mod'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 15 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 8.16 KiB | 8.16 MiB/s, done.
INFO [gitlab_clone_group] Waiting
INFO [gitlab_clone_group] Project 1/5 DF Raw Language Server
INFO [gitlab_clone_group] Cloning repo
Cloning into 'df-modding-tools__df-raw-language-server'...
remote: Enumerating objects: 6649, done.
remote: Counting objects: 100% (474/474), done.
remote: Compressing objects: 100% (456/456), done.
remote: Total 6649 (delta 218), reused 54 (delta 16), pack-reused 6175
Receiving objects: 100% (6649/6649), 16.64 MiB | 6.70 MiB/s, done.
Resolving deltas: 100% (4286/4286), done.
INFO [gitlab_clone_group] Waiting
[...]
许可证
本项目的代码采用 MIT 或 Apache 2.0 许可证。对本项目的所有贡献,包括代码和文档,都将采用类似的许可证。
依赖项
~7–23MB
~329K SLoC