Skip to content

Commit 2d90c09

Browse files
committed
review feedback
1 parent a235490 commit 2d90c09

File tree

4 files changed

+11
-29
lines changed

4 files changed

+11
-29
lines changed

command/pr_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ func computeDefaults(baseRef, headRef string) (defaults, error) {
3838
} else {
3939
out.Title = headRef // TODO format or something?
4040

41-
body := fmt.Sprintf("---\n%d commits:\n\n", len(commits))
41+
body := ""
4242
for _, c := range commits {
43-
body += fmt.Sprintf("- %s %s\n", c.Sha[0:5], c.Title)
43+
body += fmt.Sprintf("- %s\n", c.Title)
4444
}
4545
out.Body = body
4646
}
@@ -103,7 +103,7 @@ func prCreate(cmd *cobra.Command, _ []string) error {
103103

104104
defs, err := computeDefaults(baseBranch, headBranch)
105105
if err != nil {
106-
return fmt.Errorf("could not compute title or body defaults: %w", err)
106+
fmt.Fprintf(colorableErr(cmd), "%s warning: could not compute title or body defaults: %w\n", utils.Yellow("!"), err)
107107
}
108108

109109
isWeb, err := cmd.Flags().GetBool("web")

command/pr_create_test.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func TestPRCreate_survey_defaults_multicommit(t *testing.T) {
245245
}{}
246246
json.Unmarshal(bodyBytes, &reqBody)
247247

248-
expectedBody := "---\n2 commits:\n\n- 12345 commit 0\n- 23456 commit 1\n"
248+
expectedBody := "- commit 0\n- commit 1\n"
249249

250250
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID")
251251
eq(t, reqBody.Variables.Input.Title, "feature")
@@ -322,22 +322,3 @@ func TestPRCreate_survey_defaults_monocommit(t *testing.T) {
322322

323323
eq(t, output.String(), "https://github.com/OWNER/REPO/pull/12\n")
324324
}
325-
326-
func TestPRCreate_survey_defaults_no_changes(t *testing.T) {
327-
initBlankContext("OWNER/REPO", "feature")
328-
329-
http := initFakeHTTP()
330-
http.StubRepoResponse("OWNER", "REPO")
331-
332-
cs, cmdTeardown := initCmdStubber()
333-
defer cmdTeardown()
334-
335-
cs.Stub("") // git status
336-
cs.Stub("") // git log
337-
338-
_, err := RunCommand(prCreateCmd, `pr create`)
339-
if err == nil {
340-
t.Error("expected error")
341-
}
342-
eq(t, err.Error(), "could not compute title or body defaults: could not find any commits between master and feature")
343-
}

command/title_body_survey.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var SurveyAsk = func(qs []*survey.Question, response interface{}, opts ...survey
2727
return survey.Ask(qs, response, opts...)
2828
}
2929

30-
var ConfirmSubmission = func() (Action, error) {
30+
func confirmSubmission() (Action, error) {
3131
confirmAnswers := struct {
3232
Confirmation int
3333
}{}
@@ -53,7 +53,7 @@ var ConfirmSubmission = func() (Action, error) {
5353
return Action(confirmAnswers.Confirmation), nil
5454
}
5555

56-
var SelectTemplate = func(templatePaths []string) (string, error) {
56+
func selectTemplate(templatePaths []string) (string, error) {
5757
templateResponse := struct {
5858
Index int
5959
}{}
@@ -89,7 +89,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def
8989
if providedBody == "" {
9090
if len(templatePaths) > 0 {
9191
var err error
92-
templateContents, err = SelectTemplate(templatePaths)
92+
templateContents, err = selectTemplate(templatePaths)
9393
if err != nil {
9494
return nil, err
9595
}
@@ -136,7 +136,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def
136136
inProgress.Body = templateContents
137137
}
138138

139-
confirmA, err := ConfirmSubmission()
139+
confirmA, err := confirmSubmission()
140140
if err != nil {
141141
return nil, fmt.Errorf("unable to confirm: %w", err)
142142
}

git/git.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ type Commit struct {
7878

7979
func Commits(baseRef, headRef string) ([]*Commit, error) {
8080
logCmd := GitCommand(
81+
"-c", "log.ShowSignature=false",
8182
"log", "--pretty=format:%H,%s",
82-
fmt.Sprintf("%s..%s", baseRef, headRef))
83+
"--cherry", fmt.Sprintf("%s...%s", baseRef, headRef))
8384
output, err := utils.PrepareCmd(logCmd).Output()
8485
if err != nil {
8586
return []*Commit{}, err
@@ -107,7 +108,7 @@ func Commits(baseRef, headRef string) ([]*Commit, error) {
107108
}
108109

109110
func CommitBody(sha string) (string, error) {
110-
showCmd := GitCommand("show", "-s", "--pretty=format:%b", sha)
111+
showCmd := GitCommand("-c", "log.ShowSignature=false", "show", "-s", "--pretty=format:%b", sha)
111112
output, err := utils.PrepareCmd(showCmd).Output()
112113
if err != nil {
113114
return "", err

0 commit comments

Comments
 (0)