Created
February 26, 2025 09:00
-
-
Save k12u/80459862c74c981b8a37fabb3a9a6675 to your computer and use it in GitHub Desktop.
今日のお前のコミット全部 diff / log にまとめるくん
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for repo in "$@"; do | |
if [ -d "$repo/.git" ]; then | |
echo "リポジトリ: $repo" | |
# ブランチの更新順を取得 (最新50件) | |
branches=$(git --git-dir="$repo/.git" --work-tree="$repo" for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ --count=50) | |
for branch in $branches; do | |
# 昨日の0時0分0秒 (JST) のコミットIDを取得 | |
yesterday_commit=$(git --git-dir="$repo/.git" --work-tree="$repo" rev-list -n 1 --before="$(date -v-1d '+%Y-%m-%dT00:00:00+09:00')" "$branch") | |
if [ -n "$yesterday_commit" ]; then | |
# 昨日のコミットと現在の差分を取得 | |
diff_output=$(git --git-dir="$repo/.git" --work-tree="$repo" diff "$yesterday_commit" --author="$(git --git-dir="$repo/.git" --work-tree="$repo" config user.name)" "$branch") | |
# 差分がある場合のみ表示 | |
if [ -n "$diff_output" ]; then | |
echo "ブランチ: $branch" | |
# コミットメッセージ、コミット日時、作者情報を取得 (昨日の日付以降のコミットに絞り込み) | |
commit_messages=$(git --git-dir="$repo/.git" --work-tree="$repo" log --author="$(git --git-dir="$repo/.git" --work-tree="$repo" config user.name)" --after="$(date -v-1d '+%Y-%m-%dT00:00:00+09:00')" --pretty="Commit: %H%nAuthor: %an <%ae>%nDate: %ad%n%B" "$branch") | |
# コミットメッセージを表示 | |
echo "$commit_messages" | |
# PAGER を cat に設定して差分を表示 | |
echo "$diff_output" | cat | |
echo "------------------------" | |
fi | |
fi | |
done | |
else | |
echo "エラー: $repo はGitリポジトリではありません" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment