]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - ci
- script I use to commit changes
[packages/rpm-build-tools.git] / ci
CommitLineData
38573414 1#!/bin/sh
2
3SPECFILE="$1"
4SPECFILE="${SPECFILE%%/*}"
5SPECFILE="$(basename $SPECFILE .spec)"
6SPEC="$SPECFILE/$SPECFILE.spec"
7CLEANBUILDDIR="$HOME/PLD"
8
9if [ $# -ne 1 -o ! -d "$SPECFILE" -o ! -f "$SPEC" ]; then
10 echo "spec file missing"
11 exit 1
12fi
13
14diffcol()
15{
16 # vim like diff colourization
17LC_ALL=en_US.UTF-8 gawk ' {
18 split( $0, S, /\t/ );
19 $0 = S[ 1 ];
20 for ( i = 2; i in S; i++ ) {
21 spaces = 7 - ( (length( $0 ) - 1) % 8 );
22 $0 = $0 "\xE2\x9E\x94";
23 for ( y = 0; y < spaces; y++ )
24 $0 = $0 "\xE2\x87\xBE";
25 $0 = $0 S[ i ];
26 }
27 gsub( /\033/, "\033[44m^[\033[49m" );
28 cmd = "";
29 if ( sub( /^ /, "" ) )
30 cmd = " ";
31 sub( /(\xE2\x9E\x94(\xE2\x87\xBE)*| )+$/, "\033[31;41m&\033[39;49m" );
32 gsub( /\xE2\x9E\x94(\xE2\x87\xBE)*/, "\033[7m&\033[27m" );
33 gsub( /\xE2\x87\xBE/, " " );
34 $0 = cmd $0;
35 gsub( /\007/, "\033[44m^G\033[49m" );
36 gsub( /\r/, "\033[44m^M\033[49m" );
37}
38/^(Index:|diff|---|\+\+\+) / { $0 = "\033[32m" $0 }
39/^@@ / { $0 = "\033[33m" $0 }
40/^-/ { $0 = "\033[35m" $0 }
41/^+/ { $0 = "\033[36m" $0 }
42{ $0 = $0 "\033[0m"; print }
43' "$@"
44}
45
46cvs -z9 diff -u $SPECFILE | diffcol
47
48echo -n "Proceed ? "
49read ans
50
51if [ "$ans" != "y" ]; then
52 exit
53fi
54
55sed '/^# AUTO: /d' -i "$SPEC"
56SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")"
57
58./adapter "$SPEC"
59
60diff="$(cvs -z9 diff -u $SPEC)"
61
62echo "$diff" | diffcol
63
64add=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
65 END { for ( n in add ) { if ( !del[ n ] ) print n; } }' |
66 perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
67
68del=$(echo "$diff" | awk '/^\+BuildRequires/ { add[ $2 ] = 1; }; /^-BuildRequires/ { del[ $2 ] = 1; };
69 END { for ( n in del ) { if ( !add[ n ] ) print n; } }' |
70 perl -p -e 'chomp; push @a, $_; undef $_; END { print join ", ", sort @a }')
71
72n="$(echo -e '\nn')"
73n="${n%%n}"
74msg=""
75[ -n "$add" ] && msg="$msg- BR: $add$n"
76[ -n "$del" ] && msg="$msg- dropped BR: $del$n"
77
78echo
79echo "Message:"
80echo "$msg"
81echo -n "Commit ? "
82read ans
83if [ "$ans" != "y" ]; then
84 exit
85fi
86
87export COMMIT_MESSAGE="$msg"
88export COMMIT_PACKAGES="$SPECFILE"
89export VISUAL="$PWD/civim"
90cvs -z9 ci "$SPECFILE"
91
92[ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE
This page took 0.049942 seconds and 4 git commands to generate.