<commit_before>#!/bin/bash

MERGE_PREFIX="Merge branch"
BRANCH_WHITELIST="^(develop|release/.*|hotfix/.*|bugfix/.*)$"
MAJOR_RELEASE_BRANCH="release/[0-9]+\.[xX]"
MINOR_RELEASE_BRANCH="release/[0-9]+\.[0-9]+\.[xX]"
PATCH_RELEASE_BRANCH="(hot|bug)fix/.*"
MAJOR_BRANCH_PATTERN="^${MAJOR_RELEASE_BRANCH}"
MINOR_BRANCH_PATTERN="^${MINOR_RELEASE_BRANCH}"
PATCH_BRANCH_PATTERN="^${PATCH_RELEASE_BRANCH}"
MAJOR_MESSAGE_PATTERN="^${MERGE_PREFIX} '${MAJOR_RELEASE_BRANCH}'"
MINOR_MESSAGE_PATTERN="^${MERGE_PREFIX} '${MINOR_RELEASE_BRANCH}'"
PATCH_MESSAGE_PATTERN="^${MERGE_PREFIX} '${PATCH_RELEASE_BRANCH}'"

build() {
    if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
        build_branch
    else
        build_default
    fi
}

build_branch() {
#    if [ "$TRAVIS_BRANCH" == "master" ]; then
        #./gradlew $(scope_from_commit_message) final
    if [[ $TRAVIS_BRANCH =~ $BRANCH_WHITELIST ]]; then
        ./gradlew $(scope_from_branch) snapshot
    else
        build_default
    fi
}

build_default() {
    ./gradlew build
}

scope_from_branch() {
    if [[ $TRAVIS_BRANCH =~ $MAJOR_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=major
    elif [[ $TRAVIS_BRANCH =~ $MINOR_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=minor
    elif [[ $TRAVIS_BRANCH =~ $PATCH_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=patch
    fi
}

scope_from_commit_message() {
    if [[ $TRAVIS_COMMIT_MESSAGE =~ $MAJOR_MESSAGE_PATTERN ]]; then
        echo -Prelease.scope=major<commit_msg>Uncommented master release build for travis<commit_after>#!/bin/bash

MERGE_PREFIX="Merge branch"
BRANCH_WHITELIST="^(develop|release/.*|hotfix/.*|bugfix/.*)$"
MAJOR_RELEASE_BRANCH="release/[0-9]+\.[xX]"
MINOR_RELEASE_BRANCH="release/[0-9]+\.[0-9]+\.[xX]"
PATCH_RELEASE_BRANCH="(hot|bug)fix/.*"
MAJOR_BRANCH_PATTERN="^${MAJOR_RELEASE_BRANCH}"
MINOR_BRANCH_PATTERN="^${MINOR_RELEASE_BRANCH}"
PATCH_BRANCH_PATTERN="^${PATCH_RELEASE_BRANCH}"
MAJOR_MESSAGE_PATTERN="^${MERGE_PREFIX} '${MAJOR_RELEASE_BRANCH}'"
MINOR_MESSAGE_PATTERN="^${MERGE_PREFIX} '${MINOR_RELEASE_BRANCH}'"
PATCH_MESSAGE_PATTERN="^${MERGE_PREFIX} '${PATCH_RELEASE_BRANCH}'"

build() {
    if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
        build_branch
    else
        build_default
    fi
}

build_branch() {
    if [ "$TRAVIS_BRANCH" == "master" ]; then
        ./gradlew $(scope_from_commit_message) final
    elif [[ $TRAVIS_BRANCH =~ $BRANCH_WHITELIST ]]; then
        ./gradlew $(scope_from_branch) snapshot
    else
        build_default
    fi
}

build_default() {
    ./gradlew build
}

scope_from_branch() {
    if [[ $TRAVIS_BRANCH =~ $MAJOR_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=major
    elif [[ $TRAVIS_BRANCH =~ $MINOR_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=minor
    elif [[ $TRAVIS_BRANCH =~ $PATCH_BRANCH_PATTERN ]]; then
        echo -Prelease.scope=patch
    fi
}

scope_from_commit_message() {
    if [[ $TRAVIS_COMMIT_MESSAGE =~ $MAJOR_MESSAGE_PATTERN ]]; then
        echo -Prelease.scope=major
{'fraction_non_alphanumeric': 0.15579227696404793, 'fraction_numerical': 0.0039946737683089215, 'mean_word_length': 4.564814814814815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6563500', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1206, 'n_words': 150}