Skip to content

Instantly share code, notes, and snippets.

@mgoellnitz
Last active January 22, 2024 21:37
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 mgoellnitz/87daa96ca023245a93fcc2c44faac570 to your computer and use it in GitHub Desktop.
Save mgoellnitz/87daa96ca023245a93fcc2c44faac570 to your computer and use it in GitHub Desktop.
Find any non-CoreMedia-originating changes in your workspace
#!/bin/bash
#
# Find any changes in your workspace, which do not stem from the original
# CoreMedia internal sources. Optionally compare with CoreMedia or other
# git reference if there are any false positives from merges.
#
# Must be called from within workspace.
#
# Copyright 2018-2024 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
function usage {
echo "Usage: $0 [-h] [-r reference]" 1>&2
echo "" 1>&2
echo " -r reference optional additional check against given git reference (e.g. branch)" 1>&2
exit 1
}
while getopts "r:" opt ; do
case "${opt}" in
r)
REFERENCE=$OPTARG
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ ! -f workspace-configuration/extensions/README.md ] ; then
if [ ! -f ./blueprint-parent/pom.xml ] ; then
echo "$0 must be called from within CMCC-11 / CMCC-10 / CMS-9 workspace"
echo ""
usage
exit 1
fi
fi
CURRENT=$(git branch |grep -e '^*'|cut -d ' ' -f 2)
submodules=$(git submodule status|cut -d ' ' -f 3)
for f in $(find . -type f|sed -e 's/\ /xxx/g'|grep -v target|grep -v frontend.node_modules|grep -v .remote-packages|grep -v ^...git) ; do
i=$(echo $f|sed -e 's/xxx/ /g')
# echo "xx $i"
for s in $submodules ; do
# echo " s: $s"
match=$(echo $i | grep "$s" | wc -l)
if [ $match -gt 0 ] ; then
i=""
fi
done
if [ ! -z "$i" ] ; then
LINECOUNT=$(git log --format="%h %an" "$i"|grep -v coremedia-ci|grep -v Simmendinger|grep -v Bauer|grep -v Wienberg|grep -v Holtkamp|wc -l)
# TEST=$(git log --format="%h %an %s" "$i"|grep -v coremedia-ci|grep -v Simmendinger|grep -v Bauer|grep -v Wienberg|grep -v Holtkamp)
# echo "$i: $LINECOUNT ($TEST)"
if [ $LINECOUNT -gt 0 ] ; then
if [ ! -z "$REFERENCE" ] ; then
# echo $CURRENT $REFERENCE "$i"
DIFFCOUNT=$(git diff $CURRENT $REFERENCE "$i"|wc -l)
if [ $DIFFCOUNT -gt 0 ] ; then
echo $i
fi
else
echo $i
fi
# echo $i: $TEST
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment