<commit_before>#!/bin/bash
# Ensure commits in beta are in master & commits in stable are in beta + master.
set -euo pipefail
IFS=$'\n\t'

source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"

# We don't care about commits that predate this automation check, so we pass a
# `<limit>` argument to `git cherry`.
BETA_LIMIT="53fd98ca776cb875bc9e5514f56b52eb74f9e7a9"
STABLE_LIMIT="a178d0322ce20e33eac124758e837cbd80a6f633"

verify_backported_commits_main() {
  ci_base_branch=$(ciBaseBranch)

  if [[ "$ci_base_branch" != "beta" && "$ci_base_branch" != "stable" ]]; then
    echo 'Skipping. This is only run when merging to the beta or stable branches.'
    exit 0
  fi

  echo 'git: unshallowing the repository so we can check commits'
  git fetch \
    --no-tags \
    --no-recurse-submodules \
    --progress \
    --prune \
    --unshallow

  if [[ $ci_base_branch == "beta" ]]; then
    verify_cherries master "$BETA_LIMIT" \
      || exit 1

  elif [[ $ci_base_branch == "stable" ]]; then
    (verify_cherries master "$STABLE_LIMIT" \
      & verify_cherries beta "$STABLE_LIMIT") \
      || exit 1

  fi
}

# Verify all commits in `HEAD` are backports of a commit in <upstream>. See
# https://git-scm.com/docs/git-cherry for an explanation of the arguments.
#
# $1 = <upstream>
# $2 = <limit>
verify_cherries() {
  # commits that lack a `backport-of` comment.
  local no_backports=()
  # commits with an incorrect `backport-of` comment.
  local bad_backports=()<commit_msg>Do not unshallow -- already done by other code<commit_after>#!/bin/bash
# Ensure commits in beta are in master & commits in stable are in beta + master.
set -euo pipefail
IFS=$'\n\t'

source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"

# We don't care about commits that predate this automation check, so we pass a
# `<limit>` argument to `git cherry`.
BETA_LIMIT="53fd98ca776cb875bc9e5514f56b52eb74f9e7a9"
STABLE_LIMIT="a178d0322ce20e33eac124758e837cbd80a6f633"

verify_backported_commits_main() {
  ci_base_branch=$(ciBaseBranch)

  if [[ "$ci_base_branch" != "beta" && "$ci_base_branch" != "stable" ]]; then
    echo 'Skipping. This is only run when merging to the beta or stable branches.'
    exit 0
  fi

  if [[ $ci_base_branch == "beta" ]]; then
    verify_cherries master "$BETA_LIMIT" \
      || exit 1

  elif [[ $ci_base_branch == "stable" ]]; then
    (verify_cherries master "$STABLE_LIMIT" \
      & verify_cherries beta "$STABLE_LIMIT") \
      || exit 1

  fi
}

# Verify all commits in `HEAD` are backports of a commit in <upstream>. See
# https://git-scm.com/docs/git-cherry for an explanation of the arguments.
#
# $1 = <upstream>
# $2 = <limit>
verify_cherries() {
  # commits that lack a `backport-of` comment.
  local no_backports=()
  # commits with an incorrect `backport-of` comment.
  local bad_backports=()
{'fraction_non_alphanumeric': 0.1311766797013864, 'fraction_numerical': 0.03981514397440455, 'mean_word_length': 3.7373737373737375, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '2483624', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1003, 'n_words': 289}