#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
# SPDX-License-Identifier: MIT

set -ex -o pipefail

base=$(dirname "$0")

if [ -z "${GIT_BIN}" ]; then
  GIT_BIN=git
fi

"${base}/fail-if-not-git.sh"

"${base}/commit"

branch=$(git symbolic-ref HEAD --short)

while true; do
  "${GIT_BIN}" push origin "${branch}" && break
  if [ -n "${GITTED_TESTING}" ]; then
    exit 1
  fi
done
