-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_diff_msg.sh
More file actions
executable file
·56 lines (44 loc) · 1.44 KB
/
Copy pathgen_diff_msg.sh
File metadata and controls
executable file
·56 lines (44 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
file=commit_HEAD~$1.txt
echo " "
echo "-------------------------------------------"
echo "开始生成差异文本,并写入 $file!"
echo "-------------------------------------------"
echo " "
# 如果文件存在则删除
if [ -f $file ]; then
echo " "
echo "-------------------------------------------"
echo "检测到 $file 已存在,即将删除该文件!"
echo "-------------------------------------------"
echo " "
rm -f $file
fi
VERSION=""
if [ -n "$1" ]; then
echo " "
echo "-------------------------------------------"
echo "✅ 监测到传入版本参数:HEAD~$1"
echo "-------------------------------------------"
echo " "
VERSION="HEAD~$1"
fi
echo "===== 文件变更统计 =====" >>$file
echo $VERSION >>$file
echo "-------------------------------------------" >>$file
echo "===== git status =====" >>$file
echo $VERSION >>$file
echo "-------------------------------------------" >>$file
git status >>$file
echo "-------------------------------------------" >>$file
git diff --stat -w $VERSION >>$file
echo -e "\n===== 完整差异内容 =====" >>$file
git diff -w $VERSION >>$file
echo "-------------------------------------------" >>$file
echo " " >>$file
echo "===== 暂存区 文件变更统计 =====" >>$file
git diff --staged --stat -w $VERSION >>$file
echo -e "\n===== 暂存区 完整差异 =====" >>$file
git diff --staged -w $VERSION >>$file
echo "✅ 差异文件已生成:$file"
echo " "