<div dir="ltr"><div>Noice!</div><div><br></div><div>I use a slightly different coding style -- here's mine, but I don't make anyone drink my kool aid... I prefer $() to back-ticks -- they're easier to distinguish from other quotes and far easier to nest.</div><div><br></div><div>I *think* that you could replace</div><div><br></div><div>for i in $(echo $BUGS); do<br></div><div>...</div><div><br></div><div>with </div><div><br></div><div>for i in $BUGS; do<br></div><div>...</div><div><br></div><div>Haven't tested my version. Cavat Emptor.</div><div><br></div><div>Cheers,</div><div><br></div><div>--Barton</div><div> </div><div><br></div><div>#!/bin/bash</div><div><br></div><div>if [[ ! -d ~/bugs2check ]]; then</div><div>   echo "Creating report directory..."</div><div>   mkdir ~/bugs2check</div><div>fi</div><div><br></div><div>git checkout master</div><div>BRANCH=$(git status | grep "On branch" | cut -f3- -d' ')</div><div>if [[ $BRANCH != "master" ]]; then</div><div>   echo "Handle your commits first."</div><div>   exit</div><div>fi</div><div><br></div><div>echo > ~/bugs2check/REPORT</div><div>BUGS=$(git branch | grep "bug_[0-9][0-9]*$" | cut -f2 -d'_' | sort -u)</div><div>for i in $(echo $BUGS); do</div><div>   wget -O- <a href="http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i">http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i</a> > ~/bugs2check/$i 2> /dev/null</div><div>   STATUS=`grep static_bug ~/bugs2check/$i | cut -f2 -d'>'`</div><div>   echo $i - $STATUS | tee -a ~/bugs2check/REPORT</div><div>done</div><div>for STATUS in 'Pushed to Master' 'Pushed to Stable' 'CLOSED' 'RESOLVED' </div><div>do</div><div>    BUGS2DEL=$(grep "$STATUS" ~/bugs2check/REPORT | cut -f1 -d' ')</div><div>    for i in $(echo $BUGS2DEL); do</div><div>       BRANCHES=$(git branch | grep bug_$i)</div><div>       read -p "Delete $BRANCHES? " -n 1 -r</div><div>       echo    # (optional) move to a new line</div><div>       if [[ $REPLY =~ ^[Yy]$ ]]; then</div><div>           for j in $(echo $BRANCHES); do</div><div>               git branch -D $j</div><div>           done</div><div>       fi</div><div>    done</div><div>done</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 4, 2015 at 11:45 PM, Mark Tompsett <span dir="ltr"><<a href="mailto:mtompset@hotmail.com" target="_blank">mtompset@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings,<br>
<br>
If you are like me, you get a lot of branches going, and trimming back takes too much time to check if they have been pushed, etc. etc. Here’s my attempt at a script.<br>
Obviously, my branches have bug_#### on them, and a few that don’t and obviously are unrelated to bugzilla. :)<br>
<br>
Enjoy,<br>
Mark Tompsett<br>
<br>
#!/bin/bash<br>
<br>
if [[ ! -d ~/bugs2check ]]; then<br>
   echo "Creating report directory..."<br>
   mkdir ~/bugs2check<br>
fi<br>
<br>
git checkout master<br>
BRANCH=`git status | grep "On branch" | cut -f3- -d' '`<br>
if [[ $BRANCH != "master" ]]; then<br>
   echo "Handle your commits first."<br>
   exit<br>
fi<br>
<br>
echo > ~/bugs2check/REPORT<br>
BUGS=`git branch | grep "bug_[0-9][0-9]*$" | cut -f2 -d'_' | sort -u`<br>
for i in `echo $BUGS`; do<br>
   wget -O- <a href="http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i" target="_blank">http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=$i</a> > ~/bugs2check/$i 2> /dev/null<br>
   STATUS=`grep static_bug ~/bugs2check/$i | cut -f2 -d'>'`<br>
   echo $i - $STATUS | tee -a ~/bugs2check/REPORT<br>
done<br>
BUGS2DEL=`grep 'Pushed to Master' ~/bugs2check/REPORT | cut -f1 -d' '`<br>
for i in `echo $BUGS2DEL`; do<br>
   BRANCHES=`git branch | grep bug_$i`<br>
   read -p "Delete $BRANCHES? " -n 1 -r<br>
   echo    # (optional) move to a new line<br>
   if [[ $REPLY =~ ^[Yy]$ ]]; then<br>
       for j in `echo $BRANCHES`; do<br>
           git branch -D $j<br>
       done<br>
   fi<br>
done<br>
BUGS2DEL=`grep 'Pushed to Stable' ~/bugs2check/REPORT | cut -f1 -d' '`<br>
for i in `echo $BUGS2DEL`; do<br>
   BRANCHES=`git branch | grep bug_$i`<br>
   read -p "Delete $BRANCHES? " -n 1 -r<br>
   echo    # (optional) move to a new line<br>
   if [[ $REPLY =~ ^[Yy]$ ]]; then<br>
       for j in `echo $BRANCHES`; do<br>
           git branch -D $j<br>
       done<br>
   fi<br>
done<br>
BUGS2DEL=`grep 'CLOSED' ~/bugs2check/REPORT | cut -f1 -d' '`<br>
for i in `echo $BUGS2DEL`; do<br>
   BRANCHES=`git branch | grep bug_$i`<br>
   read -p "Delete $BRANCHES? " -n 1 -r<br>
   echo    # (optional) move to a new line<br>
   if [[ $REPLY =~ ^[Yy]$ ]]; then<br>
       for j in `echo $BRANCHES`; do<br>
           git branch -D $j<br>
       done<br>
   fi<br>
done<br>
BUGS2DEL=`grep 'RESOLVED' ~/bugs2check/REPORT | cut -f1 -d' '`<br>
for i in `echo $BUGS2DEL`; do<br>
   BRANCHES=`git branch | grep bug_$i`<br>
   read -p "Delete $BRANCHES? " -n 1 -r<br>
   echo    # (optional) move to a new line<br>
   if [[ $REPLY =~ ^[Yy]$ ]]; then<br>
       for j in `echo $BRANCHES`; do<br>
           git branch -D $j<br>
       done<br>
   fi<br>
done <br>
_______________________________________________<br>
Koha-devel mailing list<br>
<a href="mailto:Koha-devel@lists.koha-community.org" target="_blank">Koha-devel@lists.koha-community.org</a><br>
<a href="http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel" target="_blank">http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel</a><br>
website : <a href="http://www.koha-community.org/" target="_blank">http://www.koha-community.org/</a><br>
git : <a href="http://git.koha-community.org/" target="_blank">http://git.koha-community.org/</a><br>
bugs : <a href="http://bugs.koha-community.org/" target="_blank">http://bugs.koha-community.org/</a></blockquote></div><br></div>