5
5
output_file=" "
6
6
crate=" "
7
7
while true ; do
8
- case $1 in
9
- " --output-file" )
10
- shift
11
- output_file=" $1 "
12
- shift
13
- ;;
14
- " --crate" )
15
- shift
16
- crate=" $1 "
17
- shift
18
- ;;
19
- * )
20
- break
21
- ;;
22
- esac
8
+ case $1 in
9
+ " --output-file" )
10
+ shift
11
+ output_file=" $1 "
12
+ shift
13
+ ;;
14
+ " --crate" )
15
+ shift
16
+ crate=" $1 "
17
+ shift
18
+ ;;
19
+ * )
20
+ break
21
+ ;;
22
+ esac
23
23
done
24
24
25
25
if [[ " $output_file " == " " ]]; then
26
- echo " Missing --output-file <file> option argument, define path to file or - for stdout" && exit 1
26
+ echo " Missing --output-file <file> option argument, define path to file or - for stdout" && exit 1
27
27
fi
28
28
if [[ " $crate " == " " ]]; then
29
- echo " Missing --crate <crate> option argument, need an explisit crate to get git log for" && exit 1
29
+ echo " Missing --crate <crate> option argument, need an explisit crate to get git log for" && exit 1
30
30
fi
31
31
32
32
from_commit=HEAD
33
33
last_release=$( git tag --sort=-committerdate | grep -E " $crate -[0-9]*\.[0-9]*\.[0-9]*" | head -1)
34
34
echo " Found tag: $last_release "
35
35
if [[ " $last_release " == " " ]]; then
36
- last_release=$( git tag --sort=-committerdate | head -1) # get last tag
37
- echo " Using latest tag: $last_release "
36
+ last_release=$( git tag --sort=-committerdate | head -1) # get last tag
37
+ echo " Using latest tag: $last_release "
38
38
fi
39
39
40
40
commit_range=" "
41
41
if [[ $last_release != " " ]]; then
42
- commit_range=" $from_commit ...$last_release "
42
+ commit_range=" $from_commit ...$last_release "
43
43
else
44
- commit_range=" $from_commit "
44
+ commit_range=" $from_commit "
45
45
fi
46
46
47
47
ancestry_path=" "
48
48
if [[ " $last_release " != " " ]]; then
49
- ancestry_path=" --ancestry-path"
49
+ ancestry_path=" --ancestry-path"
50
50
fi
51
51
52
- mapfile -t log_lines < <( git log --pretty=format:' (%h) %s' $ancestry_path $commit_range )
52
+ mapfile -t log_lines < <( git log --pretty=format:' (%h) %s' $ancestry_path " $commit_range " )
53
53
54
54
function is_crate_related {
55
- commit=" $1 "
56
- changes=" $( git diff --name-only " $commit " ~ " $commit " | awk -F / ' {print $1}' | xargs) "
57
-
58
- is_related=false
59
- if [[ " $changes " == * " $crate " * ]]; then
60
- is_related=true
61
- fi
62
-
63
- echo $is_related
55
+ commit=" $1 "
56
+ changes=" $( git diff --name-only " $commit " ~ " $commit " | awk -F / ' {print $1}' | xargs) "
57
+
58
+ is_related=false
59
+ if [[ " $changes " == * " $crate " * ]]; then
60
+ is_related=true
61
+ fi
62
+
63
+ echo $is_related
64
+ }
65
+
66
+ get_username () {
67
+ commit=$1
68
+ curl -sSL \
69
+ -H " Accept: application/vnd.github+json" \
70
+ -H " X-GitHub-Api-Version: 2022-11-28" \
71
+ https://api.github.com/repos/juhaku/utoipa/commits/" $commit " | jq -r .author.login
64
72
}
65
73
66
74
log=" "
67
75
for line in " ${log_lines[@]} " ; do
68
- commit=$( echo " $line " | awk -F ' ' ' {print $1}' )
69
- commit=${commit// [\(\)]/ }
70
-
71
- if [[ $( is_crate_related " $commit " ) == true ]]; then
72
- log=$log " * $line \n"
73
- fi
76
+ commit=$( echo " $line " | awk -F ' ' ' {print $1}' )
77
+ commit=${commit// [\(\)]/ }
78
+
79
+ if [[ $( is_crate_related " $commit " ) == true ]]; then
80
+ user=$( get_username " $commit " )
81
+ log=$log " * $line @$user \n"
82
+ fi
74
83
done
75
84
76
85
if [[ " $output_file " != " " ]]; then
77
- if [[ " $output_file " == " -" ]]; then
78
- echo -e " $log "
79
- else
80
- echo -e " $log " > " $output_file "
81
- fi
86
+ if [[ " $output_file " == " -" ]]; then
87
+ echo -e " $log "
88
+ else
89
+ echo -e " $log " > " $output_file "
90
+ fi
82
91
fi
83
92
84
93
if [[ " $last_release " == " " ]]; then
85
- last_release=$( git rev-list --reverse HEAD | head -1)
94
+ last_release=$( git rev-list --reverse HEAD | head -1)
95
+ fi
96
+
97
+ if [ -n " $GITHUB_OUTPUT " ]; then
98
+ echo " last_release=$last_release " >> " $GITHUB_OUTPUT "
86
99
fi
87
- echo " ::set-output name=last_release:: $last_release "
100
+
0 commit comments