-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_completed.sh
executable file
·50 lines (46 loc) · 1.73 KB
/
clean_completed.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Copyright (C) 2015 Mark Tompsett
# Copyright (C) 2015 Barton Chittenden (status optimization loop)
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this; if not, see <http://www.gnu.org/licenses>.
if [[ ! -d ~/bugs2check ]]; then
echo "Creating report directory..."
mkdir ~/bugs2check
fi
git checkout master
BRANCH=`git status | grep "On branch" | cut -f3- -d' '`
if [[ $BRANCH != "master" ]]; then
echo "Handle your commits first."
exit
fi
echo > ~/bugs2check/REPORT
BUGS=`git branch | grep "bug_[0-9][0-9]*$" | cut -f2 -d'_' | sort -u`
for i in `echo $BUGS`; do
wget -O- http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i > ~/bugs2check/$i 2> /dev/null
STATUS=`grep static_bug ~/bugs2check/$i | cut -f2 -d'>'`
echo $i - $STATUS | tee -a ~/bugs2check/REPORT
done
for STATUS in 'Pushed to Master' 'Pushed to Stable' 'CLOSED' 'RESOLVED'; do
BUGS2DEL=`grep "$STATUS" ~/bugs2check/REPORT | cut -f1 -d' '`
for i in `echo $BUGS2DEL`; do
BRANCHES=`git branch | grep bug_$i`
read -p "Delete $BRANCHES? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
for j in `echo $BRANCHES`; do
git branch -D $j
done
fi
done
done