-
Notifications
You must be signed in to change notification settings - Fork 173
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
Create a new branch for fast forward #155
Conversation
3e85cec
to
98bb51f
Compare
Jenkins job istio-testing/pr-master passed |
98bb51f
to
28b4d52
Compare
tools/github_helper/main.go
Outdated
func (h helper) createBranchForFastForward(commit *string) (*string, error) { | ||
count := 0 | ||
|
||
for true { |
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.
please use something like fastForward/SHORTSHA
This is a test. |
Jenkins job istio-testing/pr-master passed |
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.
PTAL
This is a test. |
Jenkins job istio-testing/pr-master passed |
tools/github_helper/main.go
Outdated
@@ -93,16 +93,42 @@ func newHelper(r *string) (*helper, error) { | |||
} | |||
} | |||
|
|||
// Create a new branch for fast forward | |||
func (h helper) createBranchForFastForward(commit *string) error { | |||
branchName := fmt.Sprintf("fastForward-%s", (*commit)[0:7]) |
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.
Can we do something like fastForward/${headBranch ie master}-GIT_SHORT_SHA.
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.
It turns out we can't use "/" in branch name
tools/github_helper/main.go
Outdated
@@ -93,16 +93,42 @@ func newHelper(r *string) (*helper, error) { | |||
} | |||
} | |||
|
|||
// Create a new branch for fast forward | |||
func (h helper) createBranchForFastForward(commit *string) error { |
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.
Please pass the branch name as an argument. And generate it in createPullRequestToBase to avoid code duplication
tools/github_helper/main.go
Outdated
} | ||
|
||
newHead := fmt.Sprintf("fastForward-%s", (*commit)[0:7]) | ||
log.Printf("Created a new branch for fast forward: %s", newHead) |
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.
Move that logging to createBranchForFastForward
tools/github_helper/main.go
Outdated
// Creates a pull request from Base branch | ||
func (h helper) createPullRequestToBase(commit *string) error { | ||
if commit == nil { | ||
return errors.New("commit cannot be nil.") | ||
} | ||
|
||
if err := h.createBranchForFastForward(commit); err != nil { |
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 should probably check if the branch already exists and return nil in that case.
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.
PTAL
58911a7
to
404f773
Compare
This is a test. |
Jenkins job istio-testing/pr-master passed |
tools/github_helper/main.go
Outdated
branchName := fmt.Sprintf("fastForward-%s-%s", h.Head, (*commit)[0:7]) | ||
ref := fmt.Sprintf("refs/heads/%s", branchName) | ||
|
||
if refer, resp, err := h.Client.Git.GetRef(context.TODO(), h.Owner, h.Repo, ref); resp.StatusCode != 404 { |
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.
I don t think you need to actually get the ref, you can just look at the reponse from CreateRef.
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.
Minor changes.
This is a test. |
Jenkins job istio-testing/pr-master passed |
#113