-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCHANGELOG.sh
More file actions
executable file
·33 lines (29 loc) · 1.11 KB
/
Copy pathCHANGELOG.sh
File metadata and controls
executable file
·33 lines (29 loc) · 1.11 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
#!/bin/bash
printf "# Code Exercises\n" > README.md
printf "*Last update: $(date +%d\ %b\ %Y)*\n\n" >> README.md
last=()
list=($(ls -t $(find . -name README.md -not -path '\.\/README.md') | xargs -r0))
len=${#list[@]}
for (( numLine=0; numLine<${len}; numLine++ ));
do
line=$(dirname ${list[$numLine]})
names=(${line//\// })
namesLength=${#names[@]}
space=""
for (( i=1; i<${namesLength}-1; i++ ));
do
if [ "${names[$i]}" != "${last[$i]}" ]
then
echo "$space- **${names[$i]//-/ }**" >> README.md
fi
space="$space "
done
dir=${names[$namesLength-1]}
name="$(tr '[:lower:]' '[:upper:]' <<< ${dir:0:1})${dir:1}"
name=${name//_/: }
date=$(git log --follow --format=%cd --date=format:%d\ %b\ %Y $line/README.md | tail -n 1)
dateRelative=$(git log --follow --format=%cd --date=relative $line/README.md | tail -n 1)
echo "git log --follow --format=%cd --date=format:%d\ %b\ %Y $line/README.md - $date -- $dateRelative"
echo "$space- [${name//-/ }](${line/\.\//}) - ***$date*** *$dateRelative*" >> README.md
last=(${names[@]})
done