]> git.pld-linux.org Git - packages/rpm-build-tools.git/blob - ci
- script I use to commit changes
[packages/rpm-build-tools.git] / ci
1 #!/bin/sh
2
3 SPECFILE="$1"
4 SPECFILE="${SPECFILE%%/*}"
5 SPECFILE="$(basename $SPECFILE .spec)"
6 SPEC="$SPECFILE/$SPECFILE.spec"
7 CLEANBUILDDIR="$HOME/PLD"
8
9 if [ $# -ne 1 -o ! -d "$SPECFILE" -o ! -f "$SPEC" ]; then
10         echo "spec file missing"
11         exit 1
12 fi
13
14 diffcol()
15 {
16         # vim like diff colourization
17 LC_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
46 cvs -z9 diff -u $SPECFILE | diffcol
47
48 echo -n "Proceed ? "
49 read ans
50
51 if [ "$ans" != "y" ]; then
52         exit
53 fi
54
55 sed '/^# AUTO: /d' -i "$SPEC"
56 SIMPLE_DIFF="$(cvs -z9 diff "$SPEC")"
57
58 ./adapter "$SPEC"
59
60 diff="$(cvs -z9 diff -u $SPEC)"
61
62 echo "$diff" | diffcol
63
64 add=$(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
68 del=$(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
72 n="$(echo -e '\nn')"
73 n="${n%%n}"
74 msg=""
75 [ -n "$add" ] && msg="$msg- BR: $add$n"
76 [ -n "$del" ] && msg="$msg- dropped BR: $del$n"
77
78 echo
79 echo "Message:"
80 echo "$msg"
81 echo -n "Commit ? "
82 read ans
83 if [ "$ans" != "y" ]; then
84         exit
85 fi
86
87 export COMMIT_MESSAGE="$msg"
88 export COMMIT_PACKAGES="$SPECFILE"
89 export VISUAL="$PWD/civim"
90 cvs -z9 ci "$SPECFILE"
91
92 [ -n "$CLEANBUILDDIR" ] && rm -f $CLEANBUILDDIR/installed/$SPECFILE
This page took 0.040029 seconds and 4 git commands to generate.