|
3 | 3 | my_dir="$(dirname "$0")"
|
4 | 4 | cd $my_dir
|
5 | 5 |
|
6 |
| -source "colors.sh" |
| 6 | +source "gitlogg-utils.sh" |
7 | 7 |
|
8 | 8 | cd ..
|
9 | 9 |
|
10 | 10 | # define the absolute path to the directory that contains all your repositories.
|
11 | 11 | yourpath='./_repos/'
|
12 | 12 |
|
13 |
| -# define temporary 'git log' output file that will be parsed to 'json' |
14 |
| -tempOutputFile='_tmp/gitlogg.tmp' |
15 |
| - |
16 |
| -# ensure file exists |
17 |
| -mkdir -p ${tempOutputFile%%.*} |
18 |
| -touch $tempOutputFile |
19 |
| - |
20 | 13 | # name and path to this very script, for output message purposes
|
21 | 14 | thisFile='./scripts/gitlogg-generate-log.sh'
|
22 | 15 |
|
@@ -49,15 +42,15 @@ echo -e "${Blu}Info: Calculating in $NUM_THREADS thread(s)${RCol}"
|
49 | 42 | # ensure there's always a '/' at the end of the 'yourpath' variable, since its value can be changed by user.
|
50 | 43 | case "$yourpath" in
|
51 | 44 | */)
|
52 |
| - yourpathSanitized="${yourpath}" # no changes if there's already a slash at the end - syntax sugar |
| 45 | + yourPathSanitized="${yourpath}" # no changes if there's already a slash at the end - syntax sugar |
53 | 46 | ;;
|
54 | 47 | *)
|
55 |
| - yourpathSanitized="${yourpath}/" # add a slash at the end if there isn't already one |
| 48 | + yourPathSanitized="${yourpath}/" # add a slash at the end if there isn't already one |
56 | 49 | ;;
|
57 | 50 | esac
|
58 | 51 |
|
59 | 52 | # 'thepath' sets the path to each repository under 'yourpath' (the trailing asterix [*/] represents all the repository folders).
|
60 |
| -thepath="${yourpathSanitized}*/" |
| 53 | +thepath="${yourPathSanitized}*/" |
61 | 54 |
|
62 | 55 |
|
63 | 56 | # function to trim whitespace
|
|
85 | 78 | SECONDS=0
|
86 | 79 |
|
87 | 80 | # if the path exists and is not empty
|
88 |
| -if [ -d "${yourpathSanitized}" ] && [ "$(ls $yourpathSanitized)" ]; then |
| 81 | +if [ -d "${yourPathSanitized}" ] && [ "$(ls $yourPathSanitized)" ]; then |
89 | 82 | echo -e "${Yel}Generating ${Pur}git log ${Yel}for ${reporef} located at ${Red}'${thepath}'${Yel}. ${Blu}This might take a while!${RCol}"
|
| 83 | + |
| 84 | + # ensure file exists or create it |
| 85 | + mkdir -p ${tempOutputFile%%.*} |
| 86 | + |
90 | 87 | dirs=$(ls -d $thepath)
|
91 |
| - echo $dirs | xargs -n 1 -P $NUM_THREADS $workerFile > ${tempOutputFile} |
| 88 | + echo $dirs | xargs -n 1 -P $NUM_THREADS $workerFile |
| 89 | + |
| 90 | + cat $tempOutputFile.part.* > $tempOutputFile |
| 91 | + rm $tempOutputFile.part.* |
| 92 | + |
92 | 93 | echo -e "${Gre}The file ${Blu}${tempOutputFile} ${Gre}generated in${RCol}: ${SECONDS}s" &&
|
93 | 94 | babel "${jsonParser}" | node # only parse JSON if we have a source to parse it from
|
94 | 95 | # if the path exists but is empty
|
95 |
| -elif [ -d "${yourpathSanitized}" ] && [ ! "$(ls $yourpathSanitized)" ]; then |
| 96 | +elif [ -d "${yourPathSanitized}" ] && [ ! "$(ls $yourPathSanitized)" ]; then |
96 | 97 | echo -e "${Whi}[ERROR 002]: ${Yel}The path to the local repositories ${Red}'${yourpath}'${Yel}, which is set on the file ${Blu}'${thisFile}' ${UYel}exists, but is empty!${RCol}"
|
97 | 98 | echo -e "${Yel}Please move the repos to ${Red}'${yourpath}'${Yel} or update the variable ${Pur}'yourpath'${Yel} to reflect the absolute path to the directory where the repos are located.${RCol}"
|
98 | 99 | # if the path does not exists
|
99 |
| -elif [ ! -d "${yourpathSanitized}" ]; then |
| 100 | +elif [ ! -d "${yourPathSanitized}" ]; then |
100 | 101 | echo -e "${Whi}[ERROR 001]: ${Yel}The path to the local repositories ${Red}'${yourpath}'${Yel}, which is set on the file ${Blu}'${thisFile}' ${UYel}does not exist!${RCol}"
|
101 | 102 | echo -e "${Yel}Please create ${Red}'${yourpath}'${Yel} and move the repos under it, or update the variable ${Pur}'yourpath'${Yel} to reflect the absolute path to the directory where the repos are located.${RCol}"
|
102 | 103 | fi
|
0 commit comments