]> git.wh0rd.org - home.git/blobdiff - .bin/er-close
crostini-vapier-setup: install edge
[home.git] / .bin / er-close
index fa9ffdac5d083080478be31c43b6862a3e8d86d5..da75efd98120e164c1721c2d6ef171495fda92f0 100755 (executable)
@@ -1,9 +1,12 @@
 #!/bin/bash
 
 . ~/.profile.d/gentoo.sh
+. ~/.profile.d/aliases.sh
 
 op=${0##*/}
-op=${op%-close}
+ops=( ${op//-/ } )
+op=${ops[0]}
+[[ ${op} == "er" ]] && op+=" -q"
 tdir="${HOME}/.cache/bugz"
 mkdir -p "${tdir}"
 find "${tdir}" -mmin +30 -type f -delete
@@ -50,6 +53,11 @@ while [[ $# -ne 0 ]] ; do
                name=$(xml sel -E utf8 -t -m bugzilla/bug/long_desc -v who -n $xml | \
                        head -${c} | tail -1 | cut -d@ -f1)
        fi
+       new_name=$(echo "${name}" | scrub_html | sed "s: [(\"'][^()\"']*[)\"']::g")
+       if [[ ${new_name} != "${name}" ]] ; then
+               echo "Normalizing '${name}' to '${new_name}'"
+               name=${new_name}
+       fi
 
        if [[ -n ${cl_msg} ]] ; then
                cl_msg+="  "
@@ -72,10 +80,19 @@ doit() {
        for (( n=0; n < ${#bugs[@]}; ++n )) ; do
                b=${bugs[$n]}
                c=${comments[$n]}
-               run "$@" gbugz -q modify ${b} --fixed -c "\
+               local msg="Commit message: $c$(printf '\n%s' ${urls})"
+
+               case ${ops[1]} in
+               close)
+                       run "$@" gbugz -q modify ${b} --fixed -c "\
 should be all set now in the tree; thanks for the report!
 
-Commit message: $c$(printf '\n%s' ${urls})"
+${msg}"
+                       ;;
+               comment)
+                       run "$@" gbugz -q modify ${b} -c "${msg}"
+                       ;;
+               esac
        done
        echo
 }
@@ -100,6 +117,7 @@ case ${g} in
                t=$(mktemp)
                echo "${cmds}" > "${t}"
                ${EDITOR:-nano} "${t}" || rm "${t}"
+               set -e
                . "${t}"
                rm "${t}"
                ;;