David Caro has uploaded a new change for review.

Change subject: Added hook that sets the bug to MODIFIED
......................................................................

Added hook that sets the bug to MODIFIED

- Only if
  * product = oVirt
  * all externals are closed

Change-Id: Ifedcf594e962ab9d495bc32c48763a01890bd2a4
Signed-off-by: David Caro <[email protected]>
---
A hooks/bz/change-merged.bz.set_MODIFIED
1 file changed, 63 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/gerrit-admin refs/changes/17/15917/1

diff --git a/hooks/bz/change-merged.bz.set_MODIFIED 
b/hooks/bz/change-merged.bz.set_MODIFIED
new file mode 100755
index 0000000..e28b940
--- /dev/null
+++ b/hooks/bz/change-merged.bz.set_MODIFIED
@@ -0,0 +1,63 @@
+#!/bin/bash
+###############################################################################
+# Moves the bugs in the commit message to MODIFIED, only if it's an upstream
+# bug (meaning that belongs to one of ovirt* components) and all the external
+# bugs have been closed
+#
+# Conf options:
+#   TRACKER_NAME -> Tracker name as seen on the gerrit external tracker list
+#   BZ_USER -> Username to use when logging in to bugzilla
+#   BZ_PASS -> Password to use when logging into bugzilla
+#
+source bz.sh
+source tools.sh
+source gerrit.sh
+source conf.sh
+
+###############################################################################
+## MAIN
+## Parse the parameters
+gerrit.parse_params "$@"
+
+## Parse the configuration
+conf.load
+bz_user="${BZ_USER?No BZ_USER in the config file ${0%.*}.config}"
+bz_password="${BZ_PASS?No BZ_PASS in the config file ${0%.*}.config}"
+
+message=''
+current_patch_id="${change_url//*\/}"
+bug_ids=($(bz.get_bug_id "$commit"))
+echo "Processing bugs ${bug_ids[@]}"
+for bug_id in "${bug_ids[@]}"; do
+    bz.login -b "$bug_id" "$bz_user" "$bz_password"
+    ### Skip downstream bugs
+    product="$(bz.get_product "$bug_id")"
+    if ! [[ "$product" =~ ^oVirt$ ]]; then
+        echo "::bug $bug_id::Not an upstream bug, current product $product"
+        continue
+    fi
+    ## Check if all the external bugs are closed
+    all_merged='true'
+    for patch_id in $(bz.get_external_bugs "$bug_id" "$TRACKER_NAME"); do
+        [[ "$current_patch_id" == "$patch_id" ]] && continue
+        if $(gerrit.is_open "$patch_id"); then
+            echo "::bug $bug_id::Related patch $patch_id is still open"
+            all_merged="false"
+        fi
+    done
+    if [[ "$all_merged" != "true" ]]; then
+        echo "::bug $bug_id::Skipping because not all related patches are 
closed."
+        continue
+    fi
+    ## Modify the bug status
+    if res=$(bz.update_status "$bug_id" "MODIFIED" "$commit"); then
+        echo "::bug $bug_id::Status updated on bug #$bug_id for gerrit id" \
+             "#${change_url//*\/} to MODIFIED${res:+\n    $res}"
+    else
+        echo "::bug $bug_id::Failed to update the status of bug #$bug_id for"\
+             "gerrit id #${current_patch_id} to MODIFIED\n  $res"
+    fi
+done
+bz.clean
+gerrit.clean
+exit 0


-- 
To view, visit http://gerrit.ovirt.org/15917
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifedcf594e962ab9d495bc32c48763a01890bd2a4
Gerrit-PatchSet: 1
Gerrit-Project: gerrit-admin
Gerrit-Branch: master
Gerrit-Owner: David Caro <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to