<commit_before>#!/bin/bash

set -ex

GITHUB_DEST=$1

if echo $CI_BUILD_REF_NAME | grep private; then
  echo 'sync no private branches'
  exit 0
fi

if echo $CI_BUILD_REF_NAME | grep cherry-pick-; then
  echo 'sync no cherry-pick branches'
  exit 0
fi

if echo $CI_BUILD_REF_NAME | grep dependabot/; then
  echo 'sync no dependabot branches'
  exit 0
fi

git checkout $CI_BUILD_REF_NAME
if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  git pull --rebase origin $CI_BUILD_REF_NAME
fi

if git remote | grep github > /dev/null; then
  git remote rm github
fi
git remote add github $GITHUB_DEST

if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  git push github $CI_BUILD_REF_NAME
else
  git push github --tags
fi
<commit_msg>Maintenance: Improve sync-to-github script.<commit_after>#!/bin/bash

set -ex

GITHUB_DEST=$1

git remote prune origin

if echo $CI_BUILD_REF_NAME | grep private; then
  echo 'sync no private branches'
  exit 0
fi

if echo $CI_BUILD_REF_NAME | grep cherry-pick-; then
  echo 'sync no cherry-pick branches'
  exit 0
fi

if echo $CI_BUILD_REF_NAME | grep dependabot/; then
  echo 'sync no dependabot branches'
  exit 0
fi

git checkout $CI_BUILD_REF_NAME
if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  git reset --hard origin/$CI_BUILD_REF_NAME
fi

if git remote | grep github > /dev/null; then
  git remote rm github
fi
git remote add github $GITHUB_DEST

if [ "$CI_BUILD_REF_NAME" != "$CI_BUILD_TAG" ]; then
  git push -f github $CI_BUILD_REF_NAME
else
  git push github --tags
fi

{'fraction_non_alphanumeric': 0.0880999342537804, 'fraction_numerical': 0.005259697567389875, 'mean_word_length': 4.10738255033557, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2068429', 'n_tokens_mistral': 591, 'n_tokens_neox': 555, 'n_words': 187}