<commit_before>#!/bin/bash

# This scripts gets project version from CMakeList.txt, pom.xml or configure.ac

exec 3>&1 >/dev/tty || exec 3>&1 >./get_version_logs

if [ -f CMakeLists.txt ]
then
  echo "Getting version from CMakeLists.txt"
  mkdir check_version
  cd check_version
  echo "@PROJECT_VERSION@" > version.txt.in
  echo 'configure_file(${CMAKE_BINARY_DIR}/version.txt.in version.txt)' >> ../CMakeLists.txt
  cmake .. -DCALCULATE_VERSION_WITH_GIT=FALSE -DDISABLE_LIBRARIES_GENERATION=TRUE > /dev/null
  PROJECT_VERSION=`cat version.txt`
  echo ${PROJECT_VERSION}
  cd ..
  rm -rf check_version
  sed -i '$ d' CMakeLists.txt
elif [ -f pom.xml ]
then
  echo "Getting version from pom.xml"
  mvn help:evaluate -Dexpression=project.version
  PROJECT_VERSION=`mvn help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[" | grep -v "Down"`
elif [ -f configure.ac ]
then
  echo "Getting version from configure.ac"
  PROJECT_VERSION=`grep AC_INIT configure.ac | cut -d "," -f 2 | cut -d "[" -f 2 | cut -d "]" -f 1 | tr -d '[[:space:]]'`
elif [ -f configure.in ]
then
  echo "Getting version from configure.in"
  PROJECT_VERSION=`grep AC_INIT configure.in | cut -d "," -f 2 | cut -d "[" -f 2 | cut -d "]" -f 1 | tr -d '[[:space:]]'`
elif [ -f package.json ]
then
  echo "Getting version from package.json"
  PROJECT_VERSION=$(grep version package.json | cut -d ":" -f 2 | cut -d "\"" -f 2)
elif [ -f Makefile ]
then
  echo "Getting version from Makefile"
  PROJECT_VERSION=$(grep "DOC_VERSION =" Makefile | cut -d "=" -f 2)
elif [ -f $(find . -regex '.*/package.json' | sed -n 1p) ]
then
  echo "Getting version from package.json"
  PROJECT_VERSION=$(grep version `find . -regex '.*/package.json' | sed -n 1p` | cut -d ":" -f 2 | cut -d "\"" -f 2)  
elif [ -f $(find . -regex '.*/bower.json' | sed -n 1p) ]
then
  echo "Getting version from bower"
  PROJECT_VERSION=$(grep version `find . -regex '.*/bower.json' | sed -n 1p` | cut -d ":" -f 2 | cut -d "\"" -f 2)
else
  echo "PROJECT_VERSION not defined, need CMakeLists.txt, pom.xml, configure.ac, configure.in or package.json file"
  exit 1
fi

if [ "${PROJECT_VERSION}x" = "x" ]; then
  echo "PROJECT_VERSION not defined"
  exit 1
fi
<commit_msg>Fix js projects with version info in subfolders<commit_after>#!/bin/bash

# This scripts gets project version from CMakeList.txt, pom.xml or configure.ac

exec 3>&1 >/dev/tty || exec 3>&1 >./get_version_logs

if [ -f CMakeLists.txt ]
then
  echo "Getting version from CMakeLists.txt"
  mkdir check_version
  cd check_version
  echo "@PROJECT_VERSION@" > version.txt.in
  echo 'configure_file(${CMAKE_BINARY_DIR}/version.txt.in version.txt)' >> ../CMakeLists.txt
  cmake .. -DCALCULATE_VERSION_WITH_GIT=FALSE -DDISABLE_LIBRARIES_GENERATION=TRUE > /dev/null
  PROJECT_VERSION=`cat version.txt`
  echo ${PROJECT_VERSION}
  cd ..
  rm -rf check_version
  sed -i '$ d' CMakeLists.txt
elif [ -f pom.xml ]
then
  echo "Getting version from pom.xml"
  mvn help:evaluate -Dexpression=project.version
  PROJECT_VERSION=`mvn help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[" | grep -v "Down"`
elif [ -f configure.ac ]
then
  echo "Getting version from configure.ac"
  PROJECT_VERSION=`grep AC_INIT configure.ac | cut -d "," -f 2 | cut -d "[" -f 2 | cut -d "]" -f 1 | tr -d '[[:space:]]'`
elif [ -f configure.in ]
then
  echo "Getting version from configure.in"
  PROJECT_VERSION=`grep AC_INIT configure.in | cut -d "," -f 2 | cut -d "[" -f 2 | cut -d "]" -f 1 | tr -d '[[:space:]]'`
elif [ -f package.json ]
then
  echo "Getting version from package.json"
  PROJECT_VERSION=$(grep version package.json | cut -d ":" -f 2 | cut -d "\"" -f 2)
elif [ -f Makefile ]
then
  echo "Getting version from Makefile"
  PROJECT_VERSION=$(grep "DOC_VERSION =" Makefile | cut -d "=" -f 2)
elif [ $(find . -regex '.*/package.json' | sed -n 1p) ]
then
  echo "Getting version from package.json recursing into folders"
  PROJECT_VERSION=$(grep version `find . -regex '.*/package.json' | sed -n 1p` | cut -d ":" -f 2 | cut -d "\"" -f 2)
elif [ $(find . -regex '.*/bower.json' | sed -n 1p) ]
then
  echo "Getting version from bower recursing into folders"
  PROJECT_VERSION=$(grep version `find . -regex '.*/bower.json' | sed -n 1p` | cut -d ":" -f 2 | cut -d "\"" -f 2)
else
  echo "PROJECT_VERSION not defined, need CMakeLists.txt, pom.xml, configure.ac, configure.in or package.json file"
  exit 1
fi

if [ "${PROJECT_VERSION}x" = "x" ]; then
  echo "PROJECT_VERSION not defined"
  exit 1
fi

{'fraction_non_alphanumeric': 0.15569395017793594, 'fraction_numerical': 0.010676156583629894, 'mean_word_length': 3.4174852652259333, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '1269139', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1626, 'n_words': 513}