-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix!: branch setup for git init #138
Conversation
Codecov Report
@@ Coverage Diff @@
## main #138 +/- ##
==========================================
- Coverage 49.05% 47.52% -1.53%
==========================================
Files 6 6
Lines 424 425 +1
==========================================
- Hits 208 202 -6
- Misses 205 210 +5
- Partials 11 13 +2
|
@@ -67,6 +67,13 @@ func main() { | |||
|
|||
// Build Flags | |||
|
|||
&cli.StringFlag{ | |||
EnvVars: []string{"PARAMETER_BRANCH", "GIT_BRANCH", "VELA_PULL_REQUEST_SOURCE", "VELA_BUILD_BRANCH"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We specify the VELA_PULL_REQUEST_SOURCE
environment variable first intentionally.
This environment variable is ONLY set for pull_request
events.
This ensures the CLI library we use will try to set this value from that variable first.
In the event this plugin runs for a non pull_request
event, we then source from VELA_BUILD_BRANCH
.
If all else fails, we have a fallback value of master
to mirror the build.ref
flag:
Lines 82 to 88 in b41373c
&cli.StringFlag{ | |
EnvVars: []string{"PARAMETER_REF", "GIT_REF", "VELA_BUILD_REF"}, | |
FilePath: "/vela/parameters/git/ref,/vela/secrets/git/ref", | |
Name: "build.ref", | |
Usage: "commit reference to clone from the repo", | |
Value: "refs/heads/master", | |
}, |
love it, thanks @jbrockopp |
I'm not entirely sure the procedure for bug fixes that are breaking changes 😅 At any rate, I updated the PR description with a |
xref: go-vela/community#816
Based off of #122
This change ensures we set the expected
branch
when invokinggit init
.pull_request
events, this sets the branch forgit init
fromVELA_PULL_REQUEST_SOURCE
git init
fromVELA_BUILD_BRANCH
To test this, I set up a repo with a default branch of
main
and a.vela.yml
that looks like:Then, I created a new
context
branch which I modified theREADME.md
and opened a PR that targetsmain
.Before this change, for both the
pull_request
andpush
events, here's a snippet of output from thecontext
step:After this change, here's a snippet of output from the
context
step: