<commit_before>#!/bin/bash
set -e

function doCompile {
  if [ "$CORE" = true ] ; then
    mvn clean verify -fcore/pom.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Pcheckstyle
  fi
  if [ "$APPLICATIONS" = true ] ; then
    mvn clean verify -fapplications/pom.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Dcsstudio.composite.repo=core/p2repo -Pcheckstyle
  fi
}

function doCompileWithDeploy {
  echo "<settings><servers><server><id>s3.site</id><username>\${env.S3USER}</username><password>\${env.<PASSWORD>}</password></server></servers></settings>" > ~/settings.xml
  if [ "$CORE" = true ] ; then
    mvn clean verify -fcore/pom.xml --settings ~/settings.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -PuploadRepo
  fi
  if [ "$APPLICATIONS" = true ] ; then
    mvn clean verify -fapplications/pom.xml --settings ~/settings.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Dcsstudio.composite.repo=core/p2repo -PuploadRepo
  fi
}

function catTests {
  find ./ -type d -name "surefire-reports" -print0 | xargs -0 -I {} find {} -iname "*.txt" -type f | xargs cat
}

REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
REPO_ORG_GIT=${REPO/https:\/\/github.com\//}
REPO_ORG=${REPO_ORG_GIT/\/cs-studio\.git/}
SHA=`git rev-parse --verify HEAD`
CORE=false
APPLICATIONS=false

echo $REPO
echo $REPO_ORG
echo $SHA

while [[ $# -gt 0 ]]; do
  key="$1"

  case $key in
    -c|--core)
    CORE=true
    ;;
    -a|--applications)
    APPLICATIONS=true
    ;;
    --default)
    CORE=true
    APPLICATIONS=true
    ;;
    *)
            # unknown option
    ;;
  esac
  shift # past argument or value
done

echo "CORE=${CORE}"
echo "APP=${APPLICATIONS}"
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$REPO_ORG" == "ControlSystemStudio" ] && ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x ]] || [ "$TRAVIS_BRANCH" == "master" ]); then
    echo "Deploying"
    doCompileWithDeploy
    catTests
else<commit_msg>remove deploy from travis, move to product repo<commit_after>#!/bin/bash
set -e

function doCompile {
  if [ "$CORE" = true ] ; then
    mvn clean verify -fcore/pom.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Pcheckstyle
  fi
  if [ "$APPLICATIONS" = true ] ; then
    mvn clean verify -fapplications/pom.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Dcsstudio.composite.repo=core/p2repo -Pcheckstyle
  fi
}

function doCompileWithDeploy {
  echo "<settings><servers><server><id>s3.site</id><username>\${env.S3USER}</username><password>\${env.S3PASS}</password></server></servers></settings>" > ~/settings.xml
  if [ "$CORE" = true ] ; then
    mvn clean verify -fcore/pom.xml --settings ~/settings.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -PuploadRepo
  fi
  if [ "$APPLICATIONS" = true ] ; then
    mvn clean verify -fapplications/pom.xml --settings ~/settings.xml -Djava.net.preferIPv4Stack=true -Declipse.p2.mirrors=false -Dtycho.localArtifacts=ignore -Dcsstudio.composite.repo=core/p2repo -PuploadRepo
  fi
}

function catTests {
  find ./ -type d -name "surefire-reports" -print0 | xargs -0 -I {} find {} -iname "*.txt" -type f | xargs cat
}

REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
REPO_ORG_GIT=${REPO/https:\/\/github.com\//}
REPO_ORG=${REPO_ORG_GIT/\/cs-studio\.git/}
SHA=`git rev-parse --verify HEAD`
CORE=false
APPLICATIONS=false

echo $REPO
echo $REPO_ORG
echo $SHA

while [[ $# -gt 0 ]]; do
  key="$1"

  case $key in
    -c|--core)
    CORE=true
    ;;
    -a|--applications)
    APPLICATIONS=true
    ;;
    --default)
    CORE=true
    APPLICATIONS=true
    ;;
    *)
            # unknown option
    ;;
  esac
  shift # past argument or value
done

echo "CORE=${CORE}"
echo "APP=${APPLICATIONS}"
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
# Deploy moved to produt repo
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$REPO_ORG" == "ControlSystemStudio" ] && ([[ "$TRAVIS_BRANCH" =~ ^[0-9]+\.[0-9]+\.x ]] || [ "$TRAVIS_BRANCH" == "master" ]); then
    echo "Deploying"
    doCompile
    catTests
else
{'fraction_non_alphanumeric': 0.1642124051762606, 'fraction_numerical': 0.009147701918786257, 'mean_word_length': 3.6407867494824018, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 2, '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': '6562503', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1689, 'n_words': 335}