<commit_before>#!/bin/sh

function checkout() {
  branch=$1
  echo "*  Checking out $branch"
  git checkout $branch
  if [[ $? -ne 0 ]]; then
    echo "Git checkout of $branch branch failed" 1>&2
    exit 4
  fi
}

function pull() {
  branch=$1
  echo "*  Pulling in remote $branch"
  git pull $branch
  if [[ $? -ne 0 ]]; then
    echo "Git pull of $branch remote failed" 1>&2
    exit 5
  fi
}

function rebase() {
  branch=$1
  echo "*  Rebasing current branch onto $branch"
  git rebase $branch
  if [[ $? -ne 0 ]]; then
    echo "Git rebase to $branch failed" 1>&2
    exit 5
  fi
}

function merge() {
  branch=$1
  echo "*  Merge current branch with $branch"
  git merge $branch
  if [[ $? -ne 0 ]]; then
    echo "Git merge with $branch failed" 1>&2
    exit 6
  fi
}

function push() {
  echo "*  Pushing to origin"
  git push
  if [[ $? -ne 0 ]]; then
    echo "Git push to origin failed" 1>&2
    exit 7
  fi
}

# Exit if the repo is not under git control
git rev-parse
if [[ $? -ne 0 ]]; then
  echo "!! Current directory is not under git control. Exiting" 1>&2
  exit 1
fi

# Exit if we do not have a dev branch
git show-ref --verify --quiet refs/heads/dev
if [[ $? -ne 0 ]]; then
  echo "!! The branch dev does not exist. Cannot continue as there is nothing to merge" 1>&2
  exit 2
fi

# Exit if we are not using fast-forward merges on master
merge_strategy=$(git config --get 'branch.master.mergeoptions')
if [[ "$merge_strategy" != '--ff-only' ]]; then
  echo "!! The master branch config 'branch.master.mergeoptions' is not set to '--ff-only'. Fix please before continuing" 1>&2
  echo "!! git config --add branch.master.mergeoptions '--ff-only'" 1>&2
  exit 3
fi

dev_merge=$(git config --get branch.dev.merge)
dev_remote=$(git config --get branch.dev.remote)
if [ -n "$dev_merge" ]; then
  echo "!! The dev branch is setup to merge with '$dev_merge'. Do not do this. dev must be a local branch non-tracking branch" 1>&2
  exit 3
fi
if [ -n "$dev_remote" ]; then
  echo "!! The dev branch is tracking a remote '$dev_remote'. Do not do this. dev must be a local branch non-tracking branch" 1>&2
  exit 3
fi

# Do the master checkout & pull
checkout 'master'
pull 'origin'
<commit_msg>removing the need for --ff-only since this is different to the merge strategy needed when bringing in long topics<commit_after>#!/bin/sh

function checkout() {
  branch=$1
  echo "*  Checking out $branch"
  git checkout $branch
  if [[ $? -ne 0 ]]; then
    echo "Git checkout of $branch branch failed" 1>&2
    exit 4
  fi
}

function pull() {
  branch=$1
  echo "*  Pulling in remote $branch"
  git pull $branch
  if [[ $? -ne 0 ]]; then
    echo "Git pull of $branch remote failed" 1>&2
    exit 5
  fi
}

function rebase() {
  branch=$1
  echo "*  Rebasing current branch onto $branch"
  git rebase $branch
  if [[ $? -ne 0 ]]; then
    echo "Git rebase to $branch failed" 1>&2
    exit 5
  fi
}

function merge() {
  branch=$1
  echo "*  Merge current branch with $branch"
  git merge --ff-only $branch
  if [[ $? -ne 0 ]]; then
    echo "Git merge with $branch failed" 1>&2
    exit 6
  fi
}

function push() {
  echo "*  Pushing to origin"
  git push
  if [[ $? -ne 0 ]]; then
    echo "Git push to origin failed" 1>&2
    exit 7
  fi
}

# Exit if the repo is not under git control
git rev-parse
if [[ $? -ne 0 ]]; then
  echo "!! Current directory is not under git control. Exiting" 1>&2
  exit 1
fi

# Exit if we do not have a dev branch
git show-ref --verify --quiet refs/heads/dev
if [[ $? -ne 0 ]]; then
  echo "!! The branch dev does not exist. Cannot continue as there is nothing to merge" 1>&2
  exit 2
fi

dev_merge=$(git config --get branch.dev.merge)
dev_remote=$(git config --get branch.dev.remote)
if [ -n "$dev_merge" ]; then
  echo "!! The dev branch is setup to merge with '$dev_merge'. Do not do this. dev must be a local branch non-tracking branch" 1>&2
  exit 3
fi
if [ -n "$dev_remote" ]; then
  echo "!! The dev branch is tracking a remote '$dev_remote'. Do not do this. dev must be a local branch non-tracking branch" 1>&2
  exit 3
fi

# Do the master checkout & pull
checkout 'master'
pull 'origin'

{'fraction_non_alphanumeric': 0.12300242130750605, 'fraction_numerical': 0.019612590799031476, 'mean_word_length': 2.9721153846153845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '5490248', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1366, 'n_words': 599}