From 38573414ca438a0fe57aa4bf8bea2303ab4be67f Mon Sep 17 00:00:00 2001 From: sparky Date: Thu, 25 Feb 2010 22:21:17 +0000 Subject: [PATCH] - script I use to commit changes Changed files: ci -> 1.1 --- ci | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 ci diff --git a/ci b/ci new file mode 100644 index 0000000..5e9eb89 --- /dev/null +++ b/ci @@ -0,0 +1,92 @@ +#!/bin/sh + +SPECFILE="$1" +SPECFILE="${SPECFILE%%/*}" +SPECFILE="$(basename $SPECFILE .spec)" +SPEC="$SPECFILE/$SPECFILE.spec" +CLEANBUILDDIR="$HOME/PLD" + +if [ $# -ne 1 -o ! -d "$SPECFILE" -o ! -f "$SPEC" ]; then + echo "spec file missing" + exit 1 +fi + +diffcol() +{ + # vim like diff colourization +LC_ALL=en_US.UTF-8 gawk ' { + split( $0, S, /\t/ ); + $0 = S[ 1 ]; + for ( i = 2; i in S; i++ ) { + spaces = 7 - ( (length( $0 ) - 1) % 8 ); + $0 = $0 "\xE2\x9E\x94"; + for ( y = 0; y < spaces; y++ ) + $0 = $0 "\xE2\x87\xBE"; + $0 = $0 S[ i ]; + } + gsub( /\033/, "\033[44m^[\033[49m" ); + cmd = ""; + if ( sub( /^ /, "" ) ) + cmd = " "; + sub( /(\xE2\x9E\x94(\xE2\x87\xBE)*| )+$/, "\033[31;41m&\033[39;49m" ); + gsub( /\xE2\x9E\x94(\xE2\x87\xBE)*/, "\033[7m&\033[27m" ); + gsub( /\xE2\x87\xBE/, " " ); + $0 = cmd $0; + gsub( /\007/, "\033[44m^G\033[49m" ); + gsub( /\r/, "\033[44m^M\033[49m" ); +} +/^(Index:|diff|---|\+\+\+) / { $0 = "\033[32m" $0 } +/^@@ / { $0 = "\033[33m" $0 } +/^-/ { $0 = "\033[35m" $0 } +/^+/ { $0 = "\033[36m" $0 } +{ $0 = $0 "\033[0m"; print } +' "$@" +} + +cvs -z9 diff -u $SPECFILE | diffcol + +echo -n "Proceed ? " +read ans + +if [ "$ans" != "y" ]; then + exit +fi + +sed '/^# AUTO: /d' -i "$SPEC" +SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")" + +./adapter "$SPEC" + +diff="$(cvs -z9 diff -u $SPEC)" + +echo "$diff" | diffcol + +add=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; }; + END { for ( n in add ) { if ( !del[ n ] ) print n; } }' | + perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }') + +del=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; }; + END { for ( n in del ) { if ( !add[ n ] ) print n; } }' | + perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }') + +n="$(echo -e '\nn')" +n="${n%%n}" +msg="" +[ -n "$add" ] && msg="$msg- BR: $add$n" +[ -n "$del" ] && msg="$msg- dropped BR: $del$n" + +echo +echo "Message:" +echo "$msg" +echo -n "Commit ? " +read ans +if [ "$ans" != "y" ]; then + exit +fi + +export COMMIT_MESSAGE="$msg" +export COMMIT_PACKAGES="$SPECFILE" +export VISUAL="$PWD/civim" +cvs -z9 ci "$SPECFILE" + +[ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE -- 2.44.0