rlsbl.utils

Git helpers, version bump, changelog extraction, and other shared utilities.

Functions

run

def run(cmd, args=None, timeout=120, env=None)

Run a command with args, return trimmed stdout. Raise on failure.

is_clean_tree

def is_clean_tree()

Returns True if the git working tree is clean (no uncommitted changes).

get_current_branch

def get_current_branch()

Returns the current git branch name.

get_push_timeout

def get_push_timeout()

Return the push timeout in seconds, from RLSBL_PUSH_TIMEOUT or default 120.

push_if_needed

def push_if_needed(branch)

Push the branch to origin if local is ahead of remote.

extract_changelog_entry

def extract_changelog_entry(changelog_path, version)

Extract a changelog entry for a specific version.

Looks for a heading like '## 1.2.3' and captures everything until the next heading or EOF.

check_gh_installed

def check_gh_installed()

Check that the gh CLI is installed.

check_gh_auth

def check_gh_auth()

Check that the gh CLI is authenticated.

find_commit_tool

def find_commit_tool()

Detect safegit or fall back to git for committing.

Returns "safegit" if available on PATH, otherwise "git".

bump_version

def bump_version(version, bump_type)

Bump a semver version string by the given type (patch, minor, major).

Handles pre-release suffixes (e.g. "1.0.0-beta.1"): the suffix is stripped and the bump is applied to the base version.

Returns the new version string (always clean, no pre-release suffix).