From afac306050401193287ba3485d3ba33059763005 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Tue, 18 Jan 2011 13:04:02 +0200 Subject: 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. --- format_patch_dep3 | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 format_patch_dep3 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) -- cgit v1.2.3