Skip to content

Instantly share code, notes, and snippets.

@fuhrmanator
Last active September 18, 2021 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuhrmanator/b5b098470e7ec4536c35ca1ce3592853 to your computer and use it in GitHub Desktop.
Save fuhrmanator/b5b098470e7ec4536c35ca1ce3592853 to your computer and use it in GitHub Desktop.
Contributions script (driver) for gitinspector (LOG210, different reports for test, design, etc.)
#!/bin/bash
globalOptions="--localize-output --grading --format=html"
authorsToExcludeArray=("Christopher Fuhrman" "Yvan Ross")
reportPrefix="ContributionsÉquipe"
reportTests="${reportPrefix}Test.html"
reportModels="${reportPrefix}Modèles.html"
reportTypeScript="${reportPrefix}TypeScript.html"
reportViews="${reportPrefix}Views.html"
reportDocumentation="${reportPrefix}Docs.html"
nArgs=$#
args=("$@")
# modified from https://gist.github.com/JamieMason/4761049
function npm_package_is_installed {
# set to 1 initially
local return_=1
# set to 0 if not found
npm list -g 2>/dev/null | grep $1 >/dev/null 2>&1 || { local return_=0; }
# return value
echo "$return_"
}
function authors_to_exclude() {
local array_="${authorsToExcludeArray[@]}"
local authorsExclusionString_=""
if [ $nArgs -ge 2 ]; then # parse from command line overriding array
array_=() # reset array
for ((i=1; i < $nArgs; i++))
{
array_+=( "${args[$i]}" )
}
fi
for author in "${array_[@]}"
do
authorsExclusionString_="${authorsExclusionString_} -x \"author:${author}\""
done
# return value
echo "$authorsExclusionString_"
}
if [ $(npm_package_is_installed gitinspector) -eq 1 ]
then
if [ "$1" != "" ]; then
echo "gitinspector running on $1 : patience..."
else
printf "Usage: \e[1m$0 path/to/team/git/repo"
exit
fi
# Build the commands up in parts
authorsToExclude=$(authors_to_exclude)
# Contributions sur le plan tests
command="gitinspector -x 'file:^(?!(test))' -f ts ${globalOptions} ${authorsToExclude} $1 > \"$reportTests\" && echo \"$reportTests\""
eval $command
# Contributions sur le plan modèles
command="gitinspector -f puml,plantuml ${globalOptions} ${authorsToExclude} $1 > \"$reportModels\" && echo \"$reportModels\""
eval $command
# Contributions sur le plan documentation
command="gitinspector -f md ${globalOptions} ${authorsToExclude} $1 > \"$reportDocumentation\" && echo \"$reportDocumentation\""
eval $command
# Contributions sur le plan TypeScript
command="gitinspector -x 'file:^(?!(src))' -f ts ${globalOptions} ${authorsToExclude} $1 > \"$reportTypeScript\" && echo \"$reportTypeScript\""
eval $command
# Contributions sur le plan Views
command="gitinspector -x 'file:^(?!(views))' -f pug ${globalOptions} ${authorsToExclude} $1 > \"$reportViews\" && echo \"$reportViews\""
eval $command
else
printf "Erreur - gitinspector n'est pas installé dans npm (global).\n"
printf 'Pour utliser ce script, il faut installer le package gitinspector avec la commande:\n \e[1mnpm install -g gitinspector'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment