<commit_before>#!/bin/bash



#add-front-repository
# OK   * svnadmin create repository, if it does not exist
# OK   * copy hooks, if it does not exist
# cat, grep   * add entry to ../config/gen/user-front.properties, if it does not exist
#    * execute lens from gold to front

# TODO create help message here
#if [ $# -lt 1 -o "$1" == "--help" -o "$1" == "-h" -o "$1" == ""]; then
#  echo "Usage: $0 <config.properties> <front_list.properties>"
#  echo " - front_list should contains only new front repos"
#  exit
#fi

set -e

FRONT_REPO_NAME=$1
USER_NAME=$2


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load config file using the source command
. $DIR/../config/config.properties

SVN_FRONT_REPO_FULL_PATH=$SVN_PATH_OS/$FRONT_REPO_NAME

if [ -e $SVN_FRONT_REPO_FULL_PATH ]; then
  set +e
  svnlook info $SVN_FRONT_REPO_FULL_PATH > /dev/null 2>&1
  # The value in $RETURN_VALUE is 1 if it is not a repository
  RETURN_VALUE=$?
  set -e

  if [ 0 -ne $RETURN_VALUE ]; then
    echo "Could not create front repo \"$SVN_FRONT_REPO_FULL_PATH\", because that name is already used in that folder for a non-svn repository"
    exit 2
  fi 
  # If it is a repository, go on
fi

set +e
IS_PERMISSION_DENIED=$(svnadmin create $SVN_FRONT_REPO_FULL_PATH 2>&1 | grep "Permission denied")
set -e
if [ -n "$IS_PERMISSION_DENIED" ]; then
  echo "$IS_PERMISSION_DENIED"
fi

echo "#!/bin/sh" >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "set -e" >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "$DIR/../hooks/pre-commit \$1 \$2 " >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
chmod +x $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "Create Pre-Commit hook"

#TODO add to properties file --- ??? 


#SVN checkouts
# gold
GOLD_REPO_URL=$URL/$SVN_PATH_URL/$GOLD_REPO_NAME
# * Checkout gold to $DIR/../workspace/add-front-repository/$USER_NAME/gold
$WORKSPACE_GOLD=$DIR/../workspace/add-front-repository/$USER_NAME/gold
svn checkout "$GOLD_REPO_URL" "$WORKSPACE_GOLD" -r $REV --username $ADMIN_USER --password $<PASSWORD>

# front
FRONT_REPO_URL=$URL/$SVN_PATH_URL/$FRONT_REPO
# * Checkout front to $DIR/../workspace/add-front-repository/$USER_NAME/front
$WORKSPACE_FRONT=$DIR/../workspace/add-front-repository/$USER_NAME/front
svn checkout "$FRONT_REPO_URL" "$WORKSPACE_FRONT" --username $ADMIN_USER --password $<PASSWORD> --quiet --non-interactive
<commit_msg>Added missing properties file update<commit_after>#!/bin/bash



#add-front-repository
# OK   * svnadmin create repository, if it does not exist
# OK   * copy hooks, if it does not exist
# OK   * add entry to ../config/gen/user_front.properties, if it does not exist
# OK   * execute lens from gold to front

# TODO create help message here
#if [ $# -lt 1 -o "$1" == "--help" -o "$1" == "-h" -o "$1" == ""]; then
#  echo "Usage: $0 <config.properties> <front_list.properties>"
#  echo " - front_list should contains only new front repos"
#  exit
#fi

set -e

FRONT_REPO_NAME=$1
USER_NAME=$2


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Load config file using the source command
. $DIR/../config/config.properties

SVN_FRONT_REPO_FULL_PATH=$SVN_PATH_OS/$FRONT_REPO_NAME

if [ -e $SVN_FRONT_REPO_FULL_PATH ]; then
  set +e
  svnlook info $SVN_FRONT_REPO_FULL_PATH > /dev/null 2>&1
  # The value in $RETURN_VALUE is 1 if it is not a repository
  RETURN_VALUE=$?
  set -e

  if [ 0 -ne $RETURN_VALUE ]; then
    echo "Could not create front repo \"$SVN_FRONT_REPO_FULL_PATH\", because that name is already used in that folder for a non-svn repository"
    exit 2
  fi 
 # If it is a repository, go on
fi

set +e
IS_PERMISSION_DENIED=$(svnadmin create $SVN_FRONT_REPO_FULL_PATH 2>&1 | grep "Permission denied")
set -e
if [ -n "$IS_PERMISSION_DENIED" ]; then
  echo "$IS_PERMISSION_DENIED"
fi

echo "#!/bin/sh" >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "set -e" >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "$DIR/../hooks/pre-commit \$1 \$2 " >> $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
chmod +x $SVN_FRONT_REPO_FULL_PATH/hooks/pre-commit
echo "Create Pre-Commit hook"



set +e
IS_CONFIG_FILE_EXIST=$(cat $DIR/../config/gen/user_front.properties 1>/dev/null 2>&1)
RETURN_VALUE=$?
set -e

if [ 0 -ne $RETURN_VALUE ]; then
  echo "$USER_NAME=$FRONT_REPO" > $DIR/../config/gen/user_front.properties
else
  IS_USER_IN_CONFIG=$(cat $DIR/../config/gen/user_front.properties | grep $USER_NAME)
  if [ -z "$IS_USER_IN_CONFIG" ]; then
    echo "$USER_NAME=$FRONT_REPO" >> $DIR/../config/gen/user_front.properties
  elif [[ $IS_USER_IN_CONFIG != "$USER_NAME=$FRONT_REPO" ]]; then
    echo "Error: inconsistent user_front.properties file. Entry to be added: $USER_NAME=$FRONT_REPO; existing: $IS_USER_IN_CONFIG"
    exit 3
  fi
fi 


#SVN checkouts
# gold
GOLD_REPO_URL=$URL/$SVN_PATH_URL/$GOLD_REPO_NAME
# * Checkout gold to $DIR/../workspace/add-front-repository/$USER_NAME/gold
$WORKSPACE_GOLD=$DIR/../workspace/add-front-repository/$USER_NAME/gold
svn checkout "$GOLD_REPO_URL" "$WORKSPACE_GOLD" -r $REV --username $ADMIN_USER --password $<PASSWORD>

# front
FRONT_REPO_URL=$URL/$SVN_PATH_URL/$FRONT_REPO
# * Checkout front to $DIR/../workspace/add-front-repository/$USER_NAME/front
$WORKSPACE_FRONT=$DIR/../workspace/add-front-repository/$USER_NAME/front
svn checkout "$FRONT_REPO_URL" "$WORKSPACE_FRONT" --username $ADMIN_USER --password $<PASSWORD> --quiet --non-interactive

{'fraction_non_alphanumeric': 0.14104713992919696, 'fraction_numerical': 0.0072666294019005035, 'mean_word_length': 4.27826941986234, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 34, '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': '4814572', 'n_tokens_mistral': 2078, 'n_tokens_neox': 2014, 'n_words': 500}