<commit_before>#!/usr/bin/env bash
#
# Git specific shared functions that are used in multiple scripts.
#
# Requires functions from general.bash to be loaded.
#
# License:         MIT License
# Author:          <NAME> <<EMAIL>>
# Last modified:   26.11.2016

# Constants and globals
declare -a CASKS
declare REMOTE_PULL
declare REMOTE_PUSH
declare BRANCH_NAME

# Checks if remote is set.
#
# Arguments:
#   $1 - Remote
#
# Returns status.
git_has_remote() {
  local -a remotes
  local remote

  readonly remotes=($(git remote))
  readonly remote="$1"
  [[ -z "$*" ]] && return 1

  fgrep --word-regexp --extended-regexp -q "${remote}" <<< "${remotes[@]}"
}

# Checks if file has been changed.
#
# Arguments:
#   $1 - File
#
# Returns status.
git_file_changed() {
  local file

  readonly file="$1"
  [[ -z "$*" ]] && return 1

  git ls-files -m | fgrep --word-regexp --extended-regexp -q "${file}"
}

# Lists remote branches that start with program name.
#
# Globals:<commit_msg>Remove --extended-regexp for fgrep in git.bash<commit_after>#!/usr/bin/env bash
#
# Git specific shared functions that are used in multiple scripts.
#
# Requires functions from general.bash to be loaded.
#
# License:         MIT License
# Author:          <NAME> <<EMAIL>>
# Last modified:   26.11.2016

# Constants and globals
declare -a CASKS
declare REMOTE_PULL
declare REMOTE_PUSH
declare BRANCH_NAME

# Checks if remote is set.
#
# Arguments:
#   $1 - Remote
#
# Returns status.
git_has_remote() {
  local -a remotes
  local remote

  readonly remotes=($(git remote))
  readonly remote="$1"
  [[ -z "$*" ]] && return 1

  fgrep --word-regexp -q "${remote}" <<< "${remotes[@]}"
}

# Checks if file has been changed.
#
# Arguments:
#   $1 - File
#
# Returns status.
git_file_changed() {
  local file

  readonly file="$1"
  [[ -z "$*" ]] && return 1

  git ls-files -m | fgrep --word-regexp -q "${file}"
}

# Lists remote branches that start with program name.
#
# Globals:
{'fraction_non_alphanumeric': 0.1442455242966752, 'fraction_numerical': 0.01432225063938619, 'mean_word_length': 3.2155172413793105, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2611692', 'n_tokens_mistral': 728, 'n_tokens_neox': 673, 'n_words': 214}