Skip to content

Instantly share code, notes, and snippets.

@graste
Created October 20, 2010 18:57
Show Gist options
  • Save graste/637057 to your computer and use it in GitHub Desktop.
Save graste/637057 to your computer and use it in GitHub Desktop.
incomplete and errorprone patch<->local modified files check...
#!/bin/bash
saveIFS="$IFS"
IFS=$'\n'
diff(){
awk 'BEGIN{RS=ORS=" "}
{NR==FNR?a[$0]++:a[$0]--}
END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}
# gepatchte dateien:
patches=(`find patches -type f -regex '.*\.patch' | sed "s#^patches/##" | sed "s#\.patch##"`)
# modifizierte dateien
modified=(`svn st | grep ^M | cut -c 8- | awk -F/ '{print $NF}'`)
modified_files=(`svn st | grep ^M | cut -c 8-`)
unknown=($(diff patches[@] modified[@]))
echo ""
echo "This script compares the list of modified files with the list of patches in the patches-directory."
echo "It DOES NOT check if patches are applied correctly or if patched files are further modified."
echo ""
echo "Found patches:"
echo ${patches[@]}
echo ""
echo "Modified files:"
echo ${modified[@]}
echo ""
IFS=" "
echo "Perhaps missing files from patches directory:"
echo ""
echo ${unknown[@]}
echo ""
unknown_as_regexp=`echo ${unknown[@]} | tr -s " " "|"`
svn st | grep -E "$unknown_as_regexp"
# alias svndiff='svn diff --diff-cmd=diff -x -U0'
# svn diff | grep "^[+-\]"
# diff test.patch patches/dispatch.php.patch | grep -v dispatch.php | grep '> +'
echo ""
echo ""
IFS=$saveIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment