Enhance logic of getting current branch in case of drone #1686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey, @arturcic!
It's the 2nd PR related to Drone.
Little introduction:
DRONE_BRANCH
environment variable is equal to destination branch in case of pull request details. By this reason, in case of pull request, we need to fetch another environment variable to know current branch. Unfortunately, this is also not simple. In the1.x.x
Drone version it can be fetched fromDRONE_SOURCE_BRANCH
, however in older version it can be done by parsingCI_COMMIT_REFSPEC
environment variable, which has the following format:{sourceBranch}:{destinationBranch}
.The PR implement such logic of fetching current branch name.