-
Notifications
You must be signed in to change notification settings - Fork 283
/
make_changelog.sh
executable file
·83 lines (63 loc) · 2.37 KB
/
make_changelog.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Make Changelog original made by izdubar for Mercurial
# Update for GIT by Caio99BR <[email protected]>
(cat << EOF) > /tmp/DETAILED_CHANGELOG
Automatically Generated by make_changelog.sh. DO NOT EDIT
-----------------------------------------------------------------------------
Copyright 2009-2010, Ifcaro & jimmikaelkael
Licenced under Academic Free License version 3.0
Review Open PS2 Loader README & LICENSE files for further details.
-----------------------------------------------------------------------------
Open PS2 Loader Detailed ChangeLog:
EOF
while true
do
# Check if it have .git folder
if ! [ -d .git ]
then
echo "No .git folder found, exiting..."
break
fi
# Store author, commit and date on temp file
git log --pretty=format:"%>(18,trunc)%ci%h - %<(18)%an %s" > /tmp/commit_summary
if [ "${?}" != "0" ]
then
echo "Git command failed, exiting..."
break
fi
# Hack for fix first commit not showed
printf '\n' >> /tmp/commit_summary
# Store number of commits
old_number_commits=$(($(grep "rev" < OLD_DETAILED_CHANGELOG | head -1 | cut -d " " -f 1 | cut -c 4-)))
number_commits=$(wc -l < /tmp/commit_summary)
new_number_commits=$((number_commits - old_number_commits + 2))
# Echo it!
echo "Current Revision ${number_commits} (Of BitBucket r${old_number_commits} + Of GIT r${new_number_commits})"
# Store author, commit and date on temp file
git log -${new_number_commits} --pretty=format:"%>(18,trunc)%ci%h - %<(32)%an %s" > /tmp/commit_summary
if [ "${?}" != "0" ]
then
echo "Git command failed, exiting..."
break
fi
# Hack for fix first commit not showed
printf '\n' >> /tmp/commit_summary
# Reverse commit history
gawk '{ L[n++] = $0 } END { while(n--) print L[n] }' /tmp/commit_summary > /tmp/commit_summary_reverse
# Store each commit in one variable[list]
while read line_commit_summary
do
old_number_commits=$((old_number_commits + 1))
echo "rev${old_number_commits} - ${line_commit_summary}" >> /tmp/commit_summary_new
done < /tmp/commit_summary_reverse
# Reverse commmit history again
gawk '{ L[n++] = $0 } END { while(n--) print L[n] }' /tmp/commit_summary_new > /tmp/commit_summary
# Finish it
cat /tmp/DETAILED_CHANGELOG /tmp/commit_summary > DETAILED_CHANGELOG
# Clean it
rm -fr /tmp/commit_summary* /tmp/DETAILED_CHANGELOG*
# Echo it again!
echo "Add ${new_number_commits} revisions of GIT to DETAILED_CHANGELOG created."
# Exit
break
done