<commit_before>#!/bin/bash
set -eu -o pipefail
[[ "${DEBUG:-false}" =~ ^yes|true$ ]] && set -x

declare -f debug > /dev/null || source "$(dirname $0)/logging.sh"
declare -f is_semantic_version > /dev/null || source "$(dirname $0)/versioning.sh"
declare -f is_pull_request > /dev/null || source "$(dirname $0)/git-functions.sh"

create_release() {
    local branch="${1:-}"
    debug "Performing release from branch ${branch}."
    is_release_version "${branch}" || fatal "Not a valid release branch: '${branch}'."
    local release_version="${branch#*/}"
    debug "Detected version '${release_version}'."
    validate_version "${release_version}"
    switch_to_branch "${branch}" || create_branch "${branch}"
    log "Releasing version ${release_version} from branch ${branch}."

    local current_version="$(get_version)"
    if [[ "${current_version}" != "${release_version}" ]]; then
        log "Updating version from ${current_version} to ${release_version}."
        set_version "${release_version}"
        git commit -s -am "Release: Set project version to ${release_version}"
    else
        log "No need to update project version. It is already '${release_version}'."
    fi

    local tagname="${release_version}"
    log "Tagging published code with '${tagname}'."
    git tag -m "Publish version ${release_version}" "${tagname}"

    # Merge to master and delete local release branch
    log "Merging ${branch} to master"
    switch_to_branch master || create_branch master
    [[ "$(get_local_branch)" = "master" ]] || fatal "Could not switch to master branch."
    git merge --no-edit --ff-only "${branch}"
    git branch -d "${branch}" || warn "Could not delete local release branch '${branch}'."

    # Merge to develop and switch to next snapshot
    local nextSnapshot="$(next_snapshot_version ${release_version})"
    log "Merging to develop and updating version to '${nextSnapshot}'."
    switch_to_branch develop || create_branch develop
    [[ "$(get_local_branch)" = "develop" ]] || fatal "Could not switch to develop branch."
    git merge --no-edit master
    set_version ${nextSnapshot}
    git commit -s -am "Release: Set next development version to ${nextSnapshot}"

    log "Pushing release to origin and deleting branch '${branch}'."
    git push origin "${tagname}"
    git push origin master
    git push origin develop
    git push origin --delete "${branch}"
}

#----------------------
# MAIN
#----------------------<commit_msg>Release: Change verb in release commit from 'publish' to 'release'<commit_after>#!/bin/bash
set -eu -o pipefail
[[ "${DEBUG:-false}" =~ ^yes|true$ ]] && set -x

declare -f debug > /dev/null || source "$(dirname $0)/logging.sh"
declare -f is_semantic_version > /dev/null || source "$(dirname $0)/versioning.sh"
declare -f is_pull_request > /dev/null || source "$(dirname $0)/git-functions.sh"

create_release() {
    local branch="${1:-}"
    debug "Performing release from branch ${branch}."
    is_release_version "${branch}" || fatal "Not a valid release branch: '${branch}'."
    local release_version="${branch#*/}"
    debug "Detected version '${release_version}'."
    validate_version "${release_version}"
    switch_to_branch "${branch}" || create_branch "${branch}"
    log "Releasing version ${release_version} from branch ${branch}."

    local current_version="$(get_version)"
    if [[ "${current_version}" != "${release_version}" ]]; then
        log "Updating version from ${current_version} to ${release_version}."
        set_version "${release_version}"
        git commit -s -am "Release: Set project version to ${release_version}"
    else
        log "No need to update project version. It is already '${release_version}'."
    fi

    local tagname="${release_version}"
    log "Tagging published code with '${tagname}'."
    git tag -m "Release version ${release_version}" "${tagname}"

    # Merge to master and delete local release branch
    log "Merging ${branch} to master"
    switch_to_branch master || create_branch master
    [[ "$(get_local_branch)" = "master" ]] || fatal "Could not switch to master branch."
    git merge --no-edit --ff-only "${branch}"
    git branch -d "${branch}" || warn "Could not delete local release branch '${branch}'."

    # Merge to develop and switch to next snapshot
    local nextSnapshot="$(next_snapshot_version ${release_version})"
    log "Merging to develop and updating version to '${nextSnapshot}'."
    switch_to_branch develop || create_branch develop
    [[ "$(get_local_branch)" = "develop" ]] || fatal "Could not switch to develop branch."
    git merge --no-edit master
    set_version ${nextSnapshot}
    git commit -s -am "Release: Set next development version to ${nextSnapshot}"

    log "Pushing release to origin and deleting branch '${branch}'."
    git push origin "${tagname}"
    git push origin master
    git push origin develop
    git push origin --delete "${branch}"
}

#----------------------
# MAIN
#----------------------
{'fraction_non_alphanumeric': 0.1603451735902067, 'fraction_numerical': 0.0016054585591009432, 'mean_word_length': 3.5226860254083485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2980455', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1377, 'n_words': 489}