Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set-release-name command: Use branch name or fall back to "production" if it's a tag #206

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

Rade333
Copy link
Contributor

@Rade333 Rade333 commented Nov 28, 2024

Let's break down this shell variable assignment:

BRANCHNAME="${CIRCLE_BRANCH:-${CIRCLE_TAG:+production}}"

This is using shell parameter expansion with fallback and conditional logic. Let's break it down from inside out:

${CIRCLE_TAG:+production} 
    This is using the :+ operator
    If CIRCLE_TAG is set and not empty, it evaluates to "production"
    If CIRCLE_TAG is unset or empty, it evaluates to empty string
     

${CIRCLE_BRANCH:-...} 
    This is using the :- operator
    If CIRCLE_BRANCH is set and not empty, use its value
    If CIRCLE_BRANCH is unset or empty, use the value of what follows after :-

So putting it all together:

If CIRCLE_BRANCH is set:  
    BRANCHNAME = value of CIRCLE_BRANCH
     

If CIRCLE_BRANCH is empty/unset AND CIRCLE_TAG is set: 
    BRANCHNAME = "production"
     

If both CIRCLE_BRANCH and CIRCLE_TAG are empty/unset: 
    BRANCHNAME = empty string

@Rade333 Rade333 requested a review from Jancis November 28, 2024 13:04
@Rade333 Rade333 merged commit f800aa4 into master Dec 3, 2024
1 check passed
@Rade333 Rade333 deleted the feature/git-tags branch December 3, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants