* updated umbrello (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / scripts / Commit
blob0e8f2a1f6abc574e5f67a8d514ffd0e9b656146c
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
4 #
5 # T2 SDE: scripts/Commit
6 # Copyright (C) 2004 - 2020 The T2 SDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 force=
17 svnopt=
19 locations=
20 while [ "$1" ]; do
21 case "$1" in
22 -f) force=1 ;;
23 -svn-opt)
24 svnopt="$2"; shift ;;
26 [ ! -e "$1" -a -e `echo package/*/$1` ] &&
27 x=`echo package/*/$1` || x="$1"
28 locations="$locations $x"
30 esac
31 shift
32 done
34 if [ -z "$locations" ]; then
35 echo "Usage $0 package/files"
36 exit
39 trap 'echo "Got SIGINT (Ctrl-C)."; rm $$.log $$.diff; exit 1' INT
42 # CopyPatch and Checksum and CkSumPatch
44 svn st $locations | grep '^\(A\|M\)' | cut -c8- | while read f; do
45 if [ -f "$f" ]; then
46 scripts/Create-CopyPatch $f | patch -p0
47 if [[ $f = *.desc ]] && grep '\[D\] \+0 \+' $f; then
48 pkg=${f%.desc} pkg=${pkg##*/}
49 scripts/Create-CkSumPatch $pkg | patch -p0
52 done
54 visualize_warnings() {
55 # do not highlight just single space diff lines
56 sed '/^[+ -]./ {
57 s/\([[ \r\t]]*\)$/\o033[0;41m\1\o033[0m/
58 s/\( *\)/\o033[0;41m\1\o033[0m/
62 echo "Diff:"
63 svn diff $locations | tee $$.diff | visualize_warnings
65 # the grep -v === is a hack - somehow the svn === lines confuse awk ... ?!?
66 grep -v === $$.diff | awk "
67 BEGIN { FS=\"[ /]\" }
69 /^\+\+\+ / { pkg = \$4 }
70 { if (sub(/^\+\[I\]/,\" -\") ) { info = \$0 } }
72 /^\-\[V\] / { oldver=\$2 }
73 /^\+\[V\] / {
74 newver=\$2
75 if ( oldver )
76 print \"\t* updated \" pkg \" (\" oldver \" -> \" newver \")\"
77 else {
78 print \"\t* added \" pkg \" (\" newver \")\" info
80 oldver=\"\"; newver=\"\"; info=\"\"
83 /^\-\[P\] / { oldprio=\$4 }
84 /^\+\[P\] / {
85 newprio=\$4
86 if ( oldprio )
87 print \"\t* changed \" pkg \" build priority (\" oldprio \" -> \" newprio \")\"
88 oldprio=\"\"; newprior=\"\"
91 " > $$.log
93 function commit() {
94 svn commit $svnopt $locations --file $$.log
97 if [ -s $$.diff ]; then
98 quit=0
99 until [ $quit -ne 0 ]; do
101 echo -e "\nLog:"
102 if [ -s $$.log ]; then
103 cat $$.log
104 commit=",c=commit"
105 else
106 echo -e "\tEmpty Log File!"
107 commit=
110 echo -en "\nLog ok (q=quit,e=edit,d=diff,s=status$commit)? "
111 [ ! "$force" ] && read in || in="commit"
113 case "$in" in
114 c*) if [ -n "$commit" ]; then
115 commit; quit=1
116 fi ;;
117 d*) cat $$.diff | visualize_warnings | less -R ;;
118 s*) svn st $locations ;;
119 e*) ${EDITOR:-vi} $$.log ;;
120 q*) quit=1 ;;
121 *) echo "Excuse me?"
122 esac
123 done
124 else
125 echo -e "\nNo changes detected at:$locations"
126 svn st $locations
129 rm $$.log $$.diff