<commit_before>#!/bin/bash

#set -x

if [ $# -lt 3 ]; then
  echo "Usage:"
  echo "  $0 GIT_WORKING_DIR_PATH MAJOR MINOR [out_version_header]"
  echo "if only 3 arguments are given, script prints current string version to stdout"
  exit 1
fi

GIT_WORKING_DIR_PATH="$1"
MAJOR=$2
MINOR=$3

# Windows workaround
WIN_GIT_BIN_PATH="/C/Program Files/Git/bin"
if [ -e "$WIN_GIT_BIN_PATH" ]; then
  PATH="$WIN_GIT_BIN_PATH:$PATH"
else
  MAC_GIT_BIN_PATH1=/usr/local/git/bin
  if [ -e "$MAC_GIT_BIN_PATH1" ]; then
    PATH="$MAC_GIT_BIN_PATH1:$PATH"
  fi
  MAC_GIT_BIN_PATH2=/opt/local/bin
  if [ -e "$MAC_GIT_BIN_PATH2" ]; then
    PATH="$MAC_GIT_BIN_PATH2:$PATH"
  fi
fi

BUILD_TIMESTAMP=`date -u +%y%m%d`
BUILD_TIMESTAMP_FULL=`date -u`

GIT_CMD="git --git-dir=$GIT_WORKING_DIR_PATH/.git --work-tree=$GIT_WORKING_DIR_PATH"

GIT_COMMIT=`cd $GIT_WORKING_DIR_PATH; $GIT_CMD log --oneline -1`
GIT_COMMIT_HASH=${GIT_COMMIT:0:7}

# check if git repo has local uncommitted modifications
STRING_MODIFICATIONS=""
GIT_STATUS_OUTPUT=`cd $GIT_WORKING_DIR_PATH; $GIT_CMD status -s -uno`
if [ -n "$GIT_STATUS_OUTPUT" ]; then
  STRING_MODIFICATIONS=".altered"
fi

STRING_VER="${MAJOR}.${MINOR}.${BUILD_TIMESTAMP}.${GIT_COMMIT_HASH}${STRING_MODIFICATIONS}"

if [ $# -eq 3 ]; then
  echo $STRING_VER
  exit 0
fi

# write out header<commit_msg>Fixed paths in version generation script for windows x64 systems<commit_after>#!/bin/bash

#set -x

if [ $# -lt 3 ]; then
  echo "Usage:"
  echo "  $0 GIT_WORKING_DIR_PATH MAJOR MINOR [out_version_header]"
  echo "if only 3 arguments are given, script prints current string version to stdout"
  exit 1
fi

GIT_WORKING_DIR_PATH="$1"
MAJOR=$2
MINOR=$3

# Windows workaround
WIN_GIT_BIN_PATH1="/C/Program Files/Git/bin"
if [ -e "$WIN_GIT_BIN_PATH1" ]; then
  PATH="$WIN_GIT_BIN_PATH1:$PATH"
else
  WIN_GIT_BIN_PATH2="/C/Program Files (x86)/Git/bin"
  if [ -e "$WIN_GIT_BIN_PATH2" ]; then
    PATH="$WIN_GIT_BIN_PATH2:$PATH"
  else
    MAC_GIT_BIN_PATH1=/usr/local/git/bin
    if [ -e "$MAC_GIT_BIN_PATH1" ]; then
      PATH="$MAC_GIT_BIN_PATH1:$PATH"
    fi
    MAC_GIT_BIN_PATH2=/opt/local/bin
    if [ -e "$MAC_GIT_BIN_PATH2" ]; then
      PATH="$MAC_GIT_BIN_PATH2:$PATH"
    fi
  fi
fi

BUILD_TIMESTAMP=`date -u +%y%m%d`
BUILD_TIMESTAMP_FULL=`date -u`

GIT_CMD="git --git-dir=$GIT_WORKING_DIR_PATH/.git --work-tree=$GIT_WORKING_DIR_PATH"

GIT_COMMIT=`cd $GIT_WORKING_DIR_PATH; $GIT_CMD log --oneline -1`
GIT_COMMIT_HASH=${GIT_COMMIT:0:7}

# check if git repo has local uncommitted modifications
STRING_MODIFICATIONS=""
GIT_STATUS_OUTPUT=`cd $GIT_WORKING_DIR_PATH; $GIT_CMD status -s -uno`
if [ -n "$GIT_STATUS_OUTPUT" ]; then
  STRING_MODIFICATIONS=".altered"
fi

STRING_VER="${MAJOR}.${MINOR}.${BUILD_TIMESTAMP}.${GIT_COMMIT_HASH}${STRING_MODIFICATIONS}"

if [ $# -eq 3 ]; then
  echo $STRING_VER
  exit 0
fi

# write out header
{'fraction_non_alphanumeric': 0.136938202247191, 'fraction_numerical': 0.016151685393258428, 'mean_word_length': 4.923076923076923, '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': '2738505', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1198, 'n_words': 236}