#!/usr/bin/env bash

set -eou pipefail

if [[ "$1" != "--bazel" ]]; then
  workspace="$(builtin cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../.." && pwd)"
  source "$workspace/scripts/shell/zooxrc.sh"

  bazel_run //experimental/ryancahoon:rerun_logtests_on_jira_tickets -- --bazel "${@}"
  exit
fi

shift
for ticket in "$@"; do
  echo "Rerunning $ticket"
  ./sim/pipeline/launchers/one_shot_log_test --ignore_invalid --jira_ticket "$ticket" --alert_jira_issue "$ticket"
done
