-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from gogf/hailaz
- Loading branch information
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
# 不编码显示中文文件路径 | ||
git config --global core.quotepath false | ||
# 定义文件路径变量 | ||
CHANGELOG_FILE="docs/docs/changelog.md" | ||
echo "---" > $CHANGELOG_FILE | ||
echo "slug: '/docs/changelog'" >> $CHANGELOG_FILE | ||
echo "title: '文档更新记录'" >> $CHANGELOG_FILE | ||
echo "---" >> $CHANGELOG_FILE | ||
echo "" >> $CHANGELOG_FILE | ||
# 获取最近提交记录,只包含 .md 文件的修改 | ||
git log -n 20 --pretty=format:"- [%ad](https://github.com/gogf/gf-site/commit/%H) - [%an] - %s" --abbrev-commit --no-merges --date=format:'%m-%d %H:%M' -- '*.md' | while read -r line; do | ||
echo "$line" >> $CHANGELOG_FILE | ||
# 从输出中提取提交哈希 | ||
commit_hash=$(echo "$line" | grep -oP '(?<=commit/)[a-f0-9]+') | ||
# 显示修改的文件 | ||
if [ -n "$commit_hash" ]; then | ||
git diff-tree --no-commit-id --name-only -r "$commit_hash" -- '*.md' | while read -r changefile; do | ||
filename=$(basename "$changefile") | ||
filename="${filename%.*}" | ||
# 提取文件头中的 slug 路径 | ||
if [ -f "$changefile" ]; then | ||
slug_path=$(grep 'slug:' "$changefile" | awk -F"'" '{print $2}') | ||
title=$(grep "title: '" "$changefile" | awk -F"'" '{print $2}') | ||
if [ -n "$slug_path" ]; then | ||
if [ -z "$title" ]; then | ||
# 标题不存在的时候用文件名作为标题 | ||
title="$filename" | ||
fi | ||
echo " - [$title]($slug_path)" >> $CHANGELOG_FILE | ||
fi | ||
fi | ||
done | ||
fi | ||
echo "" >> $CHANGELOG_FILE | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ go.work.sum | |
node_modules | ||
.docusaurus | ||
output | ||
|
||
docs/docs/changelog.md | ||
|
||
# Dependencies | ||
/node_modules | ||
|