Last active
June 18, 2024 18:15
-
-
Save fuhrmanator/b5b098470e7ec4536c35ca1ce3592853 to your computer and use it in GitHub Desktop.
Contributions script (driver) for gitinspector (LOG210, different reports for test, design, etc.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# See https://github.com/ejwa/gitinspector/issues/213#issuecomment-922379023 | |
# Use (on windows) if Python is 3.8 or higher (?) | |
PATCHFILE="${USERPROFILE}/AppData/Roaming/npm/node_modules/gitinspector/gitinspector/localization.py" | |
POSIX_PATH=`cygpath $PATCHFILE` | |
# If this file exists | |
if test -f $POSIX_PATH; then | |
echo $POSIX_PATH | |
# sed -i means: inline replace (overwrite file) | |
# replace .install(True) with .install() | |
sed -i s'/.install(True)/.install()/' $POSIX_PATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment