<commit_before>#!/bin/bash

set -e
set -x

GITHUB_RUN_URL=https://nightly.link/$GITHUB_REPOSITORY/actions/runs/$RUN_ID

if [ "$EVENT" == pull_request ]
then
     PULL_REQUEST_NUMBER=$(curl \
          -H "Accept: application/vnd.github.v3+json" \
          -H "Authorization: token $GITHUB_TOKEN" \
          https://api.github.com/repos/$REPO_NAME/commits/$COMMIT_SHA/pulls 2>/dev/null \
          | jq '.[0].number')
     BRANCH=pull/$PULL_REQUEST_NUMBER/head
else
     BRANCH=$HEAD_BRANCH
fi
<commit_msg>CI Allow documentation building when the fork uses the main branch (#23937)<commit_after>#!/bin/bash

set -e
set -x

GITHUB_RUN_URL=https://nightly.link/$GITHUB_REPOSITORY/actions/runs/$RUN_ID

if [ "$EVENT" == pull_request ]
then
     PULL_REQUEST_NUMBER=$(curl \
          -H "Accept: application/vnd.github.v3+json" \
          -H "Authorization: token $GITHUB_TOKEN" \
          https://api.github.com/repos/$REPO_NAME/commits/$COMMIT_SHA/pulls 2>/dev/null \
          | jq '.[0].number')

     if [[ "$PULL_REQUEST_NUMBER" == "null" ]]; then
          # The pull request is on the main (default) branch of the fork. The above API
          # call is unable to get the PR number associated with the commit:
          # https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit
          # We fallback to the search API here. The search API is not used everytime
          # because it has a lower rate limit.
          PULL_REQUEST_NUMBER=$(curl \
               -H "Accept: application/vnd.github+json" \
               -H "Authorization: token $GITHUB_TOKEN" \
               "https://api.github.com/search/issues?q=$COMMIT_SHA+repo:$GITHUB_REPOSITORY" 2>/dev/null \
               | jq '.items[0].number')
     fi

     BRANCH=pull/$PULL_REQUEST_NUMBER/head
else
     BRANCH=$HEAD_BRANCH
fi

{'fraction_non_alphanumeric': 0.12996193583469276, 'fraction_numerical': 0.0070690592713431215, 'mean_word_length': 2.59375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 6, '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': '508673', 'n_tokens_mistral': 640, 'n_tokens_neox': 621, 'n_words': 129}