Skip to content

Commit

Permalink
fix: Fix missing bash function in allocate.sh script (#2207)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsimansk authored Mar 7, 2024
1 parent d3c24a2 commit 10153ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hack/allocate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ main() {
echo "${em}DONE${me}"
}

# Returns the current branch.
# Taken from knative/hack. The function covers Knative CI use cases and local variant.
function current_branch() {
local branch_name=""
# Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md.
# Otherwise, try getting the current branch from git.
(( IS_PROW )) && branch_name="${PULL_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="${GITHUB_BASE_REF:-}"
[[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)"
echo "${branch_name}"
}

# Returns whether the current branch is a release branch.
function is_release_branch() {
[[ $(current_branch) =~ ^release-[0-9\.]+$ ]]
Expand Down

0 comments on commit 10153ed

Please sign in to comment.