* updated gtk (4.14.4 -> 4.15.2)
[t2sde.git] / scripts / Commit
blob8da6d7c8b51ffbc30ecb35f813bb6fa20e081a5e
1 #!/usr/bin/env bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: scripts/Commit
4 # Copyright (C) 2004 - 2024 The T2 SDE Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 force=
14 cache=
15 svnopt=
16 addtxt=
17 untested=
19 locations=
20 while [ "$1" ]; do
21 case "$1" in
22 -f) force=1 ;;
23 -u|-untested) untested=1 ;;
24 -svn-opt)
25 svnopt="$2"; shift ;;
26 -add-txt)
27 addtxt="$2"; shift ;;
28 -cache)
29 cache=1 ;;
31 [ ! -e "$1" -a -e `echo package/*/$1` ] &&
32 x=`echo package/*/$1` || x="$1"
33 locations="$locations $x"
35 esac
36 shift
37 done
39 if [ -z "$locations" ]; then
40 echo "Usage $0 package | files"
41 exit
44 cleanup() {
45 local ret=$?
46 rm $$.{log,diff}
47 return 0
49 trap cleanup EXIT
51 trap 'echo "Got SIGINT (Ctrl-C)."; exit 1' INT
53 # Copy .caches if requested
55 [ "$cache" ] &&
56 for p in $locations; do
57 [[ $p != *package/*/* ]] && continue
58 p=${p#*package/*/}
59 p=${p%%/*}
60 d=$(echo package/*/$p)
61 cp -vf /var/adm/cache/$p $d/$p.cache
62 unset p d
63 done
65 # CopyPatch and Checksum and CkSumPatch
67 svn st $locations | grep '^\(A\|M\)' | cut -c8- | while read f; do
68 if [ -f "$f" ]; then
69 scripts/Create-CopyPatch $f | patch -p0
70 if [[ $f = *.desc ]] && grep '\[D\] \+0 \+' $f; then
71 pkg=${f%.desc} pkg=${pkg##*/}
72 scripts/Create-CkSumPatch $pkg | patch -p0
75 done
77 visualize_warnings() {
78 # do not highlight just single space diff lines
79 sed '/^[+ -]./ {
80 s/\([[ \r\t]]*\)$/\o033[0;41m\1\o033[0m/
81 s/\( *\)/\o033[0;41m\1\o033[0m/
85 echo "Diff:"
86 svn diff $locations | tee $$.diff | visualize_warnings
88 # the grep -v === is a hack - somehow the svn === lines confuse awk ... ?!?
89 grep -v === $$.diff | gawk "
90 BEGIN { FS=\"[ /]\" }
92 /^\+\+\+ / { pkg = \$4 }
93 { if (sub(/^\+\[I\]/,\" -\") ) { info = \$0 } }
95 /^\-\[V\] / { oldver=\$2 }
96 /^\+\[V\] / {
97 newver=\$2
98 if (oldver)
99 print \"\t* updated \" pkg \" (\" oldver \" -> \" newver \")\"
100 else {
101 print \"\t* added \" pkg \" (\" newver \")\" info
103 oldver=\"\"; newver=\"\"; info=\"\"
106 /^\-\[P\] / { oldprio=\$4 }
107 /^\+\[P\] / {
108 newprio=\$4
109 if (oldprio)
110 print \"\t* changed \" pkg \" build priority (\" oldprio \" -> \" newprio \")\"
111 oldprio=\"\"; newprior=\"\"
114 " > $$.log
116 [ "$untested" ] && sed -i -z 's/\n$/, untested\n/g' $$.log
118 [ "$addtxt" ] && sed -i "\$s|\$|$addtxt|" $$.log
120 commit() {
121 svn commit $svnopt $locations --file $$.log || exit $?
124 if [ -s $$.diff ]; then
125 quit=0
126 until [ $quit -ne 0 ]; do
128 echo -e "\nLog:"
129 if [ -s $$.log ]; then
130 cat $$.log
131 commit=",c=commit"
132 else
133 echo -e "\tEmpty Log File!"
134 commit=
137 echo -en "\nLog ok (q=quit,e=edit,d=diff,s=status$commit)? "
138 [ ! "$force" ] && read in || in="commit"
140 case "$in" in
141 c*) if [ -n "$commit" ]; then
142 commit; quit=1
143 fi ;;
144 d*) cat $$.diff | visualize_warnings | less -R ;;
145 s*) svn st $locations ;;
146 e*) ${EDITOR:-vi} $$.log ;;
147 q*) quit=1 ;;
148 *) echo "Excuse me?"
149 esac
150 done
151 else
152 echo -e "\nNo changes detected at:$locations"
153 svn st $locations