#!/usr/bin/env bash

sdir=$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd)

. "${sdir}/scripts/core/main.sh"

git_inside_work_tree() {
  git rev-parse --is-inside-work-tree >/dev/null
}

git_current_branch() {
  git branch | grep '\*' | cut -d ' ' -f2
}

git_master_branch() {
  branch="main"
  git branch | grep -qE '^[\* ]*main[ ]*$' || branch="master"
  echo "${branch}"
}

git_root() {
  git rev-parse --show-toplevel
}

git_upstream_branch() {
  git rev-parse --abbrev-ref --symbolic-full-name '@{u}'
}
