summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2011-01-18 13:04:02 +0200
committerTzafrir Cohen <tzafrir@cohens.org.il>2011-01-18 13:04:02 +0200
commitafac306050401193287ba3485d3ba33059763005 (patch)
treeaaf30a6c5e698f0976ae092276c62cbf12cbee0d
parent1a42f51b957674ddd0c69b019c8b69fa9c6e6ffe (diff)
format_patch_dep3: format patches for DEP3 headers
DEP3 is Debian's attempt to provide more standard patch information. It attempts to encode as much useful information as possible in the form of simple RFC822 headers. See http://dep.debian.net/deps/dep3/ This script should grab such useful information from Asterisk commit messages.
-rwxr-xr-xformat_patch_dep360
1 files changed, 60 insertions, 0 deletions
diff --git a/format_patch_dep3 b/format_patch_dep3
new file mode 100755
index 0000000..bd3e7ff
--- /dev/null
+++ b/format_patch_dep3
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# patch_debian: generate sensible DEP3 headers from a Asterisk commits
+
+set -e
+
+dir=''
+commit=''
+
+usage() {
+ me=`basename $0`
+ echo "$me: format a DEP3 patch from Asterisk Git-SVN commits"
+ echo ""
+ echo "Usage:"
+ echo " git format-patch --stdout COMMIT(s) | $0 # Recommended"
+ echo " git show COMMIT | $0 # Also works"
+ echo " $0 -c COMMIT [ -d DIRECTORY ] # Shortcut"
+ echo ""
+ echo " COMMIT: git commit to use. Should also work with multiple"
+ echo " patches in a mbox."
+ echo ""
+ echo " DIRECTORY: If set, use git repository from that directory"
+ echo " (change into it first)."
+}
+
+while getopts 'c:d:h' opt; do
+ case "$opt" in
+ c) commit="$OPTARG" ;;
+ d) dir="$OPTARG" ;;
+ h) usage; exit 0;;
+ ?) usage; exit 1;;
+ esac
+done
+shift $((OPTIND-1))
+
+# By default, we just grab what the user provided in the standard input
+get_patch() {
+ cat
+}
+
+if [ "$commit" != '' ]; then
+ #redefine the input function:
+ get_patch() {
+ if [ "$dir" != '' ]; then
+ cd "$dir"
+ fi
+ git format-patch --stdout "$commit"^.."$commit"
+ }
+fi
+
+
+# FIXME: ^' *' makes it work with 'git show', but increases the chance of
+# it changing the actual patch.
+get_patch \
+| sed \
+ -e 's|^ *git-svn-id: http://svn.asterisk.org/[^@]*@\([0-9]\+\) .*|Origin: http://svnview.digium.com/svn/asterisk?view=rev\&rev=\1|' \
+ -e 's|^ *(issue #\([0-9]\+\))$|Bug: https://issues.asterisk.org/view.php?id=\1|i' \
+
+#git-svn-id: git-svn-id: http://svn.asterisk.org/svn/asterisk/branches/1.4@233609
+#(issue #16299)