Skip to content

Commit

Permalink
Use Last Commit Message
Browse files Browse the repository at this point in the history
When creating a pull request
  • Loading branch information
misterMuyiwa committed Feb 2, 2016
1 parent d2b149b commit 64f4d12
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,23 @@ func CurrentBranch() (string, error) {
return strings.TrimSpace(string(result)), nil
}

func getLastCommitMessage() (string, error) {
result, err := exec.Command("git", "log", "-1", "--pretty=%B").Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(result)), nil
}

// CreateAndOpenPullRequest creates a PR on Github and opens it up in your browser
// Returns an error if you are not on a branch, or if you are not in a git repository.
func CreateAndOpenPullRequest(title string) error {
func CreateAndOpenPullRequest() error {
message, err := getLastCommitMessage()
if err != nil {
return err
}
cmd := commands.CmdRunner.Lookup("pull-request")
args := commands.NewArgs([]string{"pull-request", "-m", title, "-o"})
args := commands.NewArgs([]string{"pull-request", "-m", message, "-o"})
execError := commands.CmdRunner.Call(cmd, args)
return execError.Err
}
Expand Down

0 comments on commit 64f4d12

Please sign in to comment.