Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ glow init
"projectName": "my-project",
"gitPath": "/usr/local/bin/git",
"useBuiltInGitBindings": false,
"mergeRequest.squashCommits": true
}
```

Expand Down
11 changes: 7 additions & 4 deletions gitprovider/gitlab_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/meinto/glow"
"github.com/pkg/errors"
"github.com/spf13/viper"
)

type gitlabAdapter struct {
Expand All @@ -27,7 +28,7 @@ func (a *gitlabAdapter) Close(b glow.Branch) error {
targets := b.CloseBranches(branchList)

for _, t := range targets {
err := a.createMergeRequest(b, t)
err := a.createMergeRequest(b, t, true)
if err != nil {
return errors.Wrap(err, "error creating merge request")
}
Expand All @@ -41,24 +42,26 @@ func (a *gitlabAdapter) Publish(b glow.Branch) error {
remoteBranchExists := a.gitService.RemoteBranchExists(b.ShortBranchName())
if b.CanBePublished() && remoteBranchExists == nil {
t := b.PublishBranch()
return a.createMergeRequest(b, t)
return a.createMergeRequest(b, t, false)
}
return errors.Wrap(remoteBranchExists, "cannot be published")
}

func (a *gitlabAdapter) createMergeRequest(source glow.Branch, target glow.Branch) error {
func (a *gitlabAdapter) createMergeRequest(source glow.Branch, target glow.Branch, removeSourceBranch bool) error {
type Payload struct {
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
Title string `json:"title"`
RemoveSourceBranch bool `json:"remove_source_branch"`
Squash bool `json:"squash"`
}

data := Payload{
SourceBranch: source.ShortBranchName(),
TargetBranch: target.ShortBranchName(),
Title: fmt.Sprintf("Merge %s in %s", source.ShortBranchName(), target.ShortBranchName()),
RemoveSourceBranch: false,
RemoveSourceBranch: removeSourceBranch,
Squash: viper.GetBool("mergeRequest.squashCommits"),
}
payloadBytes, err := json.Marshal(data)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion glow.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"gitProviderDomain": "https://api.github.com",
"gitProvider": "github",
"projectNamespace": "meinto",
"projectName": "glow"
"projectName": "glow",
"mergeRequest.squashCommits": true
}