-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathgen-sub-gitinfo.sh
More file actions
27 lines (23 loc) · 968 Bytes
/
gen-sub-gitinfo.sh
File metadata and controls
27 lines (23 loc) · 968 Bytes
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
#!/bin/bash
set -e
curdir=$(cd "$(dirname $0)"; pwd -P)
target_file="${curdir}/data/sub_git_info.json"
printf "[\n" > $target_file
subs=`git config --file .gitmodules --get-regexp path | awk '{ print $2 }'`
for module in $(echo $subs);
do
cd $module
git ls-tree -r --name-only HEAD | while read filename; do
if [[ ${filename: -3} == ".md" ]]; then
msg=$(git log -1 --format="%h___%cn___%s___%ad___%H" -- $filename) # pick up useful info
msg=`echo $msg | sed 's/"//g'` # remove extra double quotes
# echo `printf '"%s___%s": "%b",' "$module" "$filename" "$msg"` >> $target_file # design json structure used in template
printf "{\n" >> $target_file
echo `printf '"name": "%s___%s",' "$module" "$filename"` >> $target_file # design json structure used in templat
echo `printf '"info": "%b"' "$msg"` >> $target_file # design json structure used in template
printf "},\n" >> $target_file
fi
done
cd $OLDPWD
done
printf '{}\n]' >> $target_file