📌  相关文章
📜  私人仓库 git history api - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:27:20.122000             🧑  作者: Mango

私人仓库 git history api - Shell-Bash

简介

私人仓库 git history api - Shell-Bash 是一个基于Shell-Bash脚本的API工具,用于查询私有Git仓库的提交历史和统计数据。该工具可以帮助程序员更好地了解仓库的变化和代码质量,从而优化代码开发流程。

功能特点
  • 查询任意时间段内的提交历史,包括作者、提交时间、提交信息等信息。
  • 按贡献者统计提交次数、代码行数、文件数等数据,方便排查代码一致性。
  • 支持自定义查询条件,如指定作者、指定分支等。
使用方法
环境依赖
  • Shell-Bash环境
  • Git仓库
安装方法
$ git clone https://github.com/username/repo.git
$ cd repo
$ chmod +x git-history-api.sh
使用示例
$ ./git-history-api.sh --repo=/path/to/repo.git --start-date=2022-01-01 --end-date=2022-01-31

$ ./git-history-api.sh --repo=ssh://git@example.com/path/to/repo.git --start-date=2022-01-01 --end-date=2022-01-31
参数说明

| 参数 | 说明 | | ----------------- | ------------------------------------------------------------ | | --repo=/path/to/repo.git | Git仓库的路径或URL地址 | | --start-date=2022-01-01 | 开始日期,格式为 yyyy-mm-dd | | --end-date=2022-01-31 | 结束日期,格式为 yyyy-mm-dd | | --author=username | 指定作者 | | --branch=master | 指定分支 | | --output=markdown | 输出格式,支持markdown和json,默认为markdown |

输出样例
# Git Commit History

Repository: /path/to/repo.git

Period: 2022-01-01 ~ 2022-01-31

## Commits

| Author | Date | Message |
|--------|------|---------|
| Alice | 2022-01-02 | add feature A |
| Bob | 2022-01-05 | fix bug B |
| Charlie | 2022-01-11 | update documentation |
| Alice | 2022-01-15 | add feature C |
| Alice | 2022-01-25 | refactor code D |

## Contributors

| Author | Commits | Insertions | Deletions | Files Changed |
|--------|---------|------------|-----------|---------------|
| Alice | 3 | 100 | 50 | 10 |
| Bob | 1 | 20 | 10 | 5 |
| Charlie | 1 | 30 | 15 | 2 |

参考链接
  1. Git History - How to git log for Git repository
  2. Git Basics - Viewing the Commit History