Created
April 14, 2020 14:38
-
-
Save nseinlet/82b82395b2bf1761896c039491255e00 to your computer and use it in GitHub Desktop.
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 | |
RED='\e[31m' | |
GREEN='\e[32m' | |
BLUE='\e[34m' | |
NC='\e[39m' # No Colo | |
REP1="odoo" | |
REP2="enterprise" | |
base_dir="/datas/src-migrations/diffs" | |
if [ -z "$2" ] | |
then | |
echo "No argument supplied" | |
echo "Usage = gen_diffs.sh old_ver new_ver [-p|--path path] [-o|--output external_tool]" | |
echo "Ex : gen_diffs.sh saas-11.1 saas-11.2" | |
echo " If no external tool is provided, diff2html output is used" | |
exit 1 | |
fi | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-p|--path) | |
path="$2" | |
shift # past argument | |
shift # past value | |
;; | |
-o|--output) | |
tool="$2" | |
shift # past argument | |
shift # past value | |
;; | |
*) # unknown option | |
POSITIONAL+=("$1") # save it in an array for later | |
shift # past argument | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" # restore positional parameters | |
echo "From version : $1" | |
echo "To version : $2" | |
echo "Output : $tool" | |
echo "Limited to path: $path" | |
for repo in $REP1 $REP2 | |
do | |
echo -e "${GREEN}update ${BLUE}${repo}${NC}" | |
cd /datas/progs/${repo} && git fetch origin | |
echo -e "${RED}diff ${BLUE}${repo}${NC}" | |
if [ -z "$tool" ] | |
then | |
cd /datas/progs/${repo} && git diff --no-prefix origin/$1..origin/$2 -- $path | filterdiff -X ~/filterdiff.patterns | /usr/local/bin/diff2html -i stdin -F ${base_dir}/diff-$2-${repo}.html | |
else | |
$tool < $(cd /datas/progs/${repo} && git diff --no-prefix origin/$1..origin/$2 -- $path | filterdiff -X ~/filterdiff.patterns) | |
fi | |
done | |
echo -e "${GREEN}Finished.${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment