<commit_before>#!/bin/bash

release_utility_release(){
  local is_major
  local is_patch
  local is_beta
  local is_force
  local last
  local version
  local confirm
  local release_commit
  local release_prefix
  local release_version_prefix
  local release_branch
  local release_command

  release_command=$1; shift

  while getopts fbmph OPT; do
    case $OPT in
      m)
        is_major=1
        ;;
      p)
        is_patch=1
        ;;
      b)
        is_beta=1
        ;;
      f)
        is_force=1
        ;;
      h)
        release_usage
        exit 1
        ;;
    esac
  done

  release_commit=$(git log -1 --format="%H")
  release_utility_check_status

  release_prefix
  release_version_prefix="release:${release_prefix}version-"
  last=$(git log --format="%s" --grep="$release_version_prefix" | head -1)
  last=${last#$release_version_prefix}
  release_utility_next_version

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

  echo "branch:  $release_branch"
  echo "version: $version"
  read -p "OK? [y/n] " confirm
  case "$confirm" in
    y*)
      echo "version: $version release start..."
      release_prepare
      git commit --allow-empty -m "$release_version_prefix$version"
      git push origin $release_branch
      release_main
      ;;
    *)
      echo "abort"
      exit 1
      ;;
  esac
}
release_usage(){
  echo "usage: ./release.sh [-m] [-p] [-b] [-f]"
}
release_prefix(){
  : # release_prefix=PREFIX
}
release_prepare(){
  : # prepare
}
release_main(){
  echo "override release_main function"
}
release_utility_check_status(){
  if [ -z "$(git log --remotes="origin" --format="%H" | grep $release_commit)" ]; then
    echo "ローカルの HEAD ($release_commit) が origin に push されていません"
    exit 1
  fi

  if [ -n "$(git status --short)" ]; then
    if [ -z "$is_force" ]; then
      echo "commit されていない変更が残っています"
      echo "もしこのままリリースしてしまいたいなら -f を指定してください"
      exit 1
    fi
  fi
}
release_utility_next_version(){
  local major
  local minor
  local patch
  local tip<commit_msg>pull していないコミットがある場合キャンセルするように修正<commit_after>#!/bin/bash

release_utility_release(){
  local is_major
  local is_patch
  local is_beta
  local is_force
  local last
  local version
  local confirm
  local release_commit
  local release_prefix
  local release_version_prefix
  local release_branch
  local release_command

  release_command=$1; shift

  while getopts fbmph OPT; do
    case $OPT in
      m)
        is_major=1
        ;;
      p)
        is_patch=1
        ;;
      b)
        is_beta=1
        ;;
      f)
        is_force=1
        ;;
      h)
        release_usage
        exit 1
        ;;
    esac
  done

  release_commit=$(git log -1 --format="%H")
  release_branch=$(git symbolic-ref --short HEAD)

  release_utility_check_status

  release_prefix
  release_version_prefix="release:${release_prefix}version-"
  last=$(git log --format="%s" --grep="$release_version_prefix" | head -1)
  last=${last#$release_version_prefix}
  release_utility_next_version

  echo "branch:  $release_branch"
  echo "version: $version"
  read -p "OK? [y/n] " confirm
  case "$confirm" in
    y*)
      echo "version: $version release start..."
      release_prepare
      git commit --allow-empty -m "$release_version_prefix$version"
      git push origin $release_branch
      release_main
      ;;
    *)
      echo "abort"
      exit 1
      ;;
  esac
}
release_usage(){
  echo "usage: ./release.sh [-m] [-p] [-b] [-f]"
}
release_prefix(){
  : # release_prefix=PREFIX
}
release_prepare(){
  : # prepare
}
release_main(){
  echo "override release_main function"
}
release_utility_check_status(){
  if [ -z "$(git log --remotes="origin" --format="%H" | grep $release_commit)" ]; then
    echo "ローカルの HEAD ($release_commit) が origin に push されていません"
    exit 1
  fi

  echo git fetch --tags --prune
  git fetch -q --tags --prune
  if [ -n "$(git log ${release_branch}..origin/${release_branch})" ]; then
    echo "origin に pull していないコミットがあります"
    exit 1
  fi

  if [ -n "$(git status --short)" ]; then
    if [ -z "$is_force" ]; then
      echo "commit されていない変更が残っています"
      echo "もしこのままリリースしてしまいたいなら -f を指定してください"
      exit 1
    fi
  fi
}
release_utility_next_version(){
  local major
  local minor
  local patch
  local tip
{'fraction_non_alphanumeric': 0.11359360301034807, 'fraction_numerical': 0.005409219190968956, 'mean_word_length': 2.6663793103448277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5866313', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1476, 'n_words': 372}