Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

fix(mr): Use default branch on mr create #630

Merged
merged 2 commits into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions commands/mr/create/mr_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,6 @@ func repoRemote(labClient *gitlab.Client, opts *CreateOpts, repo glrepo.Interfac
}

func getTargetBranch(baseRepoRemote *glrepo.Remote, sourceBranch string) string {
branchConfig := git.ReadBranchConfig(sourceBranch)
// Check if our given git.BranchConfig{} is not empty, otherwise it will fail
// if try to access the fields, this is needed because the ReadBranchConfig
// function can return an empty struct
if branchConfig != (git.BranchConfig{}) {
if branchConfig.RemoteName != "" && branchConfig.MergeRef != "" {
// The MergeRef takes the form of refs/head/BRANCH_NAME, so split it
// by '/' and get the last element
branchName := strings.Split(branchConfig.MergeRef, "/")
return branchName[len(branchName)-1]
}
}
br, _ := git.GetDefaultBranch(baseRepoRemote.PushURL.String())
// we ignore the error since git.GetDefaultBranch returns master and an error
// if the default branch cannot be determined
Expand Down
1 change: 0 additions & 1 deletion commands/mr/create/mr_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func TestNewCmdCreate_tty(t *testing.T) {

cs, csTeardown := test.InitCmdStubber()
defer csTeardown()
cs.Stub("")
cs.Stub("HEAD branch: master\n")
cs.Stub(heredoc.Doc(`
deadbeef HEAD
Expand Down