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

Use the environment variable GIT_BRANCH as the current branch everywhere #3049

Closed

Conversation

asbjornu
Copy link
Member

Currently, the environment variable GIT_BRANCH is used to override which branch the GitPreparer uses for its logic. This PR expands that usage to the entire codebase by moving the logic from GitPreparer to GitVersionContextFactory.

I will add documentation for this when time allows.

Related Issue

Fixes #2900.

Motivation and Context

It's unintuitive that GIT_BRANCH can be used to override the branch name only for normalization and not for version calculation.

How Has This Been Tested?

I added a test and refactored the plumbing a bit so it's easier to set environment variables inside a test.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Don't just use the environment variable GIT_BRANCH in GitPreparer
to find the current branch; allow GIT_BRANCH to specify which branch
is being built in the GitVersionContext as well, so it can be used
throughout the codebase.

Fixes GitToolsGH-2900.
@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@bassarisse
Copy link

Hi!

Would this affect GitHub Action?

I've been wanting to avoid using the PR version format for builds made from PR's, but since this build agent uses only the GITHUB_REF env var I can't currently override this, AFAIK.

@arturcic
Copy link
Member

@asbjornu I will close this draft as it's already too old. I opened a new issue #3954 that you might consider implementing

@arturcic arturcic closed this Mar 13, 2024
@asbjornu asbjornu deleted the feature/branch-from-env branch March 13, 2024 21:29
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.

Using Bitbucket Pipelines the current branch can not be evaluated when on develop branch
4 participants