git:每日更新日志

发布于 2024-09-04 20:29:03 字数 401 浏览 3 评论 0原文

如何生成按日期分组的提交的变更日志,格式为:

[date today]
- commit message1
- commit message2
- commit message3
...
[date day+3]
- commit message1
- commit message2
- commit message3
...
(skip this day if no commits)

[date day+1]
- commit message1
- commit message2
- commit message3
... 
[date since]
- commit message1
- commit message2
- commit message3

任何 git log 命令或智能 bash 脚本?

How to generate changelog of commits groupped by date, in format:

[date today]
- commit message1
- commit message2
- commit message3
...
[date day+3]
- commit message1
- commit message2
- commit message3
...
(skip this day if no commits)

[date day+1]
- commit message1
- commit message2
- commit message3
... 
[date since]
- commit message1
- commit message2
- commit message3

Any git log command, or smart bash script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

深者入戏 2024-09-11 20:29:03

这是我想出的脚本的肮脏但有效的版本:

#!/bin/bash
# Generates changelog day by day
NEXT=$(date +%F)
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
    echo
    echo [$DATE]
    GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
    NEXT=$DATE
done

Here is dirty, but working version of the script I came up with:

#!/bin/bash
# Generates changelog day by day
NEXT=$(date +%F)
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
    echo
    echo [$DATE]
    GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
    NEXT=$DATE
done
如何视而不见 2024-09-11 20:29:03

我无法得到处理今天提交的可接受的答案,因为我的设置在第一次迭代时没有正确处理 NEXT 变量。 Git 的日志参数也接受时间,这样就不需要 NEXT 日期:

#!/bin/bash
# Generates changelog day by day
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
    echo
    echo [$DATE]
    GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
done

I couldn't get the accepted answer to handle today's commits as my setup didn't handle the NEXT variable properly on the first iteration. Git's log parameters will accept a time too, which removes the need for a NEXT date:

#!/bin/bash
# Generates changelog day by day
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
    echo
    echo [$DATE]
    GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
done
知足的幸福 2024-09-11 20:29:03

git log--since--until,围绕它包装一些东西应该不难。

git log has --since and --until, it shouldn't be hard to wrap some stuff around that.

眼泪淡了忧伤 2024-09-11 20:29:03

这肯定需要某种脚本。
有点像这样 commandline-fu

for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r

(不完全是你想要的,但仍然可以给你一个想法)

我知道GitStats 也包含按日期组织的数据(但不是提交消息)


注意:此命令的 gitbranch 部分是不适合脚本编写,如 Jakub Narębski 评论。
git for-each-refgit show-ref 是脚本命令的自然候选者,是管道命令。

That would require most certainly some kind of script.
A bit like this commandline-fu

for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r

(not exactly what you are after but can gives you an idea nonetheless)

I know about GitStats which has also data organized by date (but not the commit messages)


Note: the git branch part of this command is ill-fitted for scripting, as Jakub Narębski comments.
git for-each-ref or git show-ref are natural candidate for scripting commands, being plumbing commands.

洒一地阳光 2024-09-11 20:29:03

我用 python 编写了一个脚本来创建每周的 git 日志。

您可以通过更改时间增量轻松将其更改为天、月等

https://gist.github.com/纳希姆纳赛尔/4772132

I wrote a script in python to create a week-by-week git log.

You could easily change it to days, months, etc by changing the timedelta

https://gist.github.com/NahimNasser/4772132

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文