#git-repository #log-file #git #log #generator #version-control #gource

app rource

一个帮助你为所有仓库生成 Gource 日志的工具

4 个版本

0.3.1 2023 年 12 月 31 日
0.3.0 2023 年 12 月 31 日
0.2.1 2023 年 12 月 29 日
0.2.0 2023 年 12 月 29 日

#439 in 开发工具

Apache-2.0

335KB
745

Rource

这是什么?

Rource 是一个工具,可以从 git 仓库或包含 git 仓库的目录生成 Gource 日志文件。

如果你不知道 Gource 是什么,可以在这里查看:https://github.com/acaudwell/Gource

这是一个工具,可以从日志文件(通常是源代码控制系统)生成酷炫的视觉效果,例如这样

Gource Video

如何使用它?

给 rource 提供一个 git 仓库的路径或包含仓库的目录的路径,它将生成一个 Gource 日志文件。

您可以选择是否递归搜索仓库,也可以指定要包含或排除的仓库。

Rource 还支持用户名别名,因此您可以将各种 git 用户名映射到更简洁、更易显示在 Gource 中的名称。它还支持 shell 展开,因此如果您愿意,可以使用 ~ 来引用您的家目录。

示例

递归扫描文件夹以查找 git 仓库,应用两个别名并将输出写入文件

rource -p ~/source/my-github-org -r --alias "AdamLeyshon::WelshProgrammer" --alias "SomeOtherUsername::WelshProgrammer" -o output.txt

递归扫描文件夹以查找 git 仓库,应用两个别名并将输出直接管道到 Gource

rource -p ~/source/my-github-org -r | gource - --log-format custom

为单个仓库生成日志并直接管道到 Gource

rource -p ~/source/my-github-org/my-repo | gource - --log-format custom

为该仓库生成日志并写入文件

rource -p ./ -o output.txt

如何获取它?

crates.io 安装

安装过程应该非常简单

cargo install rource

从源码构建/安装

git clone https://github.com/AdamLeyshon/rource.git 
cd rource

# You can either install it
cargo install --path .

# Or build it, the binary will be in ./target/release/rource
cargo build --release

可用选项

Rource! A tool to convert git logs into a format that can be used by Gource.

WARNING: When used with large quantities of repositories or a repository with many commits, Rource can generate very large files.
In some cases you may need to use the --use-merge-sort option, please read the documentation for this option for more info.

Usage: rource [OPTIONS] --path <PATH>

Options:
    -p, --path <PATH>
        The path to the git repository/repositories
    
    -r, --recursive
        Recursively search for repositories, by default all repositories in <PATH> will be included
    
    -i, --include <INCLUDE>
        Used with recursive, only process these repositories, cannot be used with --exclude
    
    -e, --exclude <EXCLUDE>
        Used with recursive, exclude these repositories from processing, cannot be used with --include
    
    -o, --output <OUTPUT>
        Output file, writes to stdout if not specified
    
    -a, --alias <ALIAS>
        Add an alias for a user, the format is <USERNAME>::<REPLACEMENT>,
        If a username contains pipes (|), they are automatically be replaced with '#' before aliases are applied,
        If you want to alias 'Some|User', your alias should be 'Some#User::SomeUser'.
        You can specify this option multiple times
    
    -m, --use-merge-sort
        Use Merge Sort, required when processing large quantities of commits.
        Be aware that when using the merge sort, you will need at least 3x the size of the final log file in free disk space.
        For example, when used against the Rust repository, the final output is 64GB but the temporary space needed is upto 192GB.
        Please also read the documentation for --sort-chunk-size and --temp-file-location for additional controls
    
    --sort-chunk-size <SORT_CHUNK_SIZE>
        Chunk size in Megabytes (Min: 64 MB), Merge sort will try to limit RAM usage to this amount, however it is not a hard limit and should be viewed as a hint, by default it will use 4 GB. Depending on the number of commits, more RAM will help speed up the sort/merge phase
    
    -t, --temp-file-location <TEMP_FILE_LOCATION>
        Location to store temporary files, by default this will randomly named directory in the current working path, if the program is interrupted you may need to delete this directory manually
    
    -z, --max-changeset-size <MAX_CHANGESET_SIZE>
        Commits with a changeset larger than this will be filtered out, this is useful for ignoring commits that are likely to be merges, tags or CI/CD commits
    
    -h, --help
        Print help (see a summary with '-h')
    
    -V, --version
        Print version

提示

GitHub 组织

如果您在一个拥有许多 GitHub 仓库的组织中工作,您可以使用 GH CLI 将它们全部克隆到本地,然后使用 rource 为它们生成日志文件。

# Make a directory to clone all the repos into
mkdir ~/source/my-github-org
cd ~/source/my-github-org

# Login first if you haven't already
gh auth login

# Then clone all the repos, depending on the size, this may take a long time!
gh repo list <your-org-name> --limit 4000 | while read -r repo _; do
  gh repo clone "$repo" "$repo"                                                         
done

# Then generate the log file, plus an example to set an alias for a user and exclude an external repo 
rource -p ~/source/my-github-org -r --alias "GithubUsername::Friendly Name" -e "ADependencyLibrary" -o output.txt

依赖项

~19–31MB
~545K SLoC