-
Notifications
You must be signed in to change notification settings - Fork 1
/
changelog.sh
executable file
·78 lines (68 loc) · 2.41 KB
/
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
#!/bin/bash
#************************************************#
# #
# Kernel #
# changelog generator #
# modded by @anarkia1976 #
# written by @fusionjack #
# #
#************************************************#
# colorize and add text parameters
grn=$(tput setaf 2) # green
yellow=$(tput setaf 3) # yellow
bldgrn=${txtbld}$(tput setaf 2) # bold green
red=$(tput setaf 1) # red
txtbld=$(tput bold) # bold
bldblu=${txtbld}$(tput setaf 4) # bold blue
blu=$(tput setaf 4) # blue
txtrst=$(tput sgr0) # reset
blink=$(tput blink) # blink
# variables
rdir=`pwd`
CURRENT_DATE=`date +%Y%m%d`
LAST_DATE=`date +%s -d "15 day ago"`
CUSTOM_DATE="$1"
clear
echo -e "${bldgrn}"
echo " ";
echo " Yarpiin Kernel ";
echo " ";
echo -e "${txtrst}"
# generate changelog
echo -e "${blink}${bldblu} *** Generating Changelog ${txtrst}"; echo "";
if [ -z "$CUSTOM_DATE" ]; then
if [ -z "$LAST_DATE" ]; then
WORKING_DATE=`date +%s "1 day ago"`
else
WORKING_DATE=${LAST_DATE}
fi
else
WORKING_DATE=${CUSTOM_DATE}
fi
CHANGELOG=$rdir/changelog_${CURRENT_DATE}.txt
# remove existing changelog
file="$CHANGELOG"
if [ -f "$file" ]; then
echo -e "${txtbld}${red} *** Removing Old Changelog${txtrst}"; echo"";
rm $CHANGELOG;
fi
# find the directories to log
find $rdir -name .git | sed 's/\/.git//g' | sed 'N;$!P;$!D;$d' | while read line
do
cd $line
# test to see if the repo needs to have a changelog written.
log=$((git log --pretty="* %s (%an) [%h]" --no-merges --since=$WORKING_DATE --date-order) | sed 's/\.git//')
project=$(git remote -v | grep -i origin | head -n1 | awk '{print $2}' | sed 's/.*\///' | sed 's/\.git//')
if [ ! -z "$log" ]; then
# write the changelog
echo -e "${txtbld}${yellow} *** Verify Changelog Status ${txtrst}";
echo -e "${grn} ----> $project: is Updated ${txtrst}"; echo "";
echo "" >> $CHANGELOG;
echo "Project name: $project" >> $CHANGELOG;
echo "$log" | while read line
do
echo " $line" >> $CHANGELOG
done
echo "" >> $CHANGELOG
fi
done