Skip to content

Commit 5132c5d

Browse files
committed
horrid slopwip
1 parent 0417599 commit 5132c5d

File tree

1 file changed

+143
-1
lines changed

1 file changed

+143
-1
lines changed

command/pr_review.go

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,12 @@ func prReview(cmd *cobra.Command, args []string) error {
145145
}
146146

147147
if patchMode {
148-
fmt.Fprintln(out, "FLIP MODE")
148+
reviewData, err = patchReview(cmd)
149+
if err != nil {
150+
return err
151+
}
152+
// for now just return
153+
fmt.Fprintln(out, "done with patch mode, stopping here for now")
149154
return nil
150155
}
151156

@@ -286,3 +291,140 @@ func reviewSurvey(cmd *cobra.Command) (*api.PullRequestReviewInput, error) {
286291
State: reviewState,
287292
}, nil
288293
}
294+
295+
func patchReview(cmd *cobra.Command) (*api.PullRequestReviewInput, error) {
296+
type Hunk struct {
297+
File string
298+
Diff string
299+
}
300+
301+
hunks := []Hunk{
302+
{"diff --git a/command/pr_review.go b/command/pr_review.go",
303+
`@@ -11,7 +11,8 @@ import (
304+
)
305+
306+
func init() {
307+
- prCmd.AddCommand(prReviewCmd)
308+
+ // TODO re-register post release
309+
+ // prCmd.AddCommand(prReviewCmd)
310+
311+
prReviewCmd.Flags().BoolP("approve", "a", false, "Approve pull request")
312+
prReviewCmd.Flags().BoolP("request-changes", "r", false, "Request changes on a pull request")
313+
`},
314+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
315+
`@@ -8,6 +8,7 @@ import (
316+
)
317+
318+
func TestPRReview_validation(t *testing.T) {
319+
+ t.Skip("skipping until release is done")
320+
initBlankContext("", "OWNER/REPO", "master")
321+
http := initFakeHTTP()
322+
for _, cmd := range []string{
323+
`},
324+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
325+
`@@ -22,6 +23,7 @@ func TestPRReview_validation(t *testing.T) {
326+
}
327+
328+
func TestPRReview_url_arg(t *testing.T) {
329+
+ t.Skip("skipping until release is done")
330+
initBlankContext("", "OWNER/REPO", "master")
331+
http := initFakeHTTP()
332+
http.StubRepoResponse("OWNER", "REPO")
333+
`},
334+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
335+
`@@ -67,6 +69,7 @@ func TestPRReview_url_arg(t *testing.T) {
336+
}
337+
338+
func TestPRReview_number_arg(t *testing.T) {
339+
+ t.Skip("skipping until release is done")
340+
initBlankContext("", "OWNER/REPO", "master")
341+
http := initFakeHTTP()
342+
http.StubRepoResponse("OWNER", "REPO")
343+
`},
344+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
345+
`@@ -112,6 +115,7 @@ func TestPRReview_number_arg(t *testing.T) {
346+
}
347+
348+
func TestPRReview_no_arg(t *testing.T) {
349+
+ t.Skip("skipping until release is done")
350+
initBlankContext("", "OWNER/REPO", "feature")
351+
http := initFakeHTTP()
352+
http.StubRepoResponse("OWNER", "REPO")
353+
`},
354+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
355+
`@@ -147,6 +151,7 @@ func TestPRReview_no_arg(t *testing.T) {
356+
}
357+
358+
func TestPRReview_blank_comment(t *testing.T) {
359+
+ t.Skip("skipping until release is done")
360+
initBlankContext("", "OWNER/REPO", "master")
361+
http := initFakeHTTP()
362+
http.StubRepoResponse("OWNER", "REPO")`},
363+
364+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
365+
`@@ -156,6 +161,7 @@ func TestPRReview_blank_comment(t *testing.T) {
366+
}
367+
368+
func TestPRReview_blank_request_changes(t *testing.T) {
369+
+ t.Skip("skipping until release is done")
370+
initBlankContext("", "OWNER/REPO", "master")
371+
http := initFakeHTTP()
372+
http.StubRepoResponse("OWNER", "REPO")
373+
}
374+
375+
`},
376+
377+
{"diff --git a/command/pr_review_test.go b/command/pr_review_test.go",
378+
`@@ -165,6 +171,7 @@ func TestPRReview_blank_request_changes(t *testing.T) {
379+
func TestPRReview(t *testing.T) {
380+
+ t.Skip("skipping until release is done")
381+
type c struct {
382+
Cmd string
383+
ExpectedEvent string
384+
`},
385+
386+
{"diff --git a/command/root.go b/command/root.go",
387+
`@@ -271,7 +271,7 @@ func rootHelpFunc(command *cobra.Command, s []string) {
388+
s := " " + rpad(c.Name()+":", c.NamePadding()) + c.Short
389+
if includes(coreCommandNames, c.Name()) {
390+
coreCommands = append(coreCommands, s)
391+
- } else {
392+
+ } else if c != creditsCmd {
393+
additionalCommands = append(additionalCommands, s)
394+
}
395+
}`},
396+
}
397+
out := colorableOut(cmd)
398+
399+
fmt.Fprintln(out, "- starting review ~/.config/gh/reviews/0001.json")
400+
fmt.Fprintln(out, "You are going to review 9 changes across 3 files")
401+
402+
cont := false
403+
continueQs := []*survey.Question{
404+
{
405+
Name: "continue",
406+
Prompt: &survey.Confirm{
407+
Message: "Continue?",
408+
Default: true,
409+
},
410+
},
411+
}
412+
413+
err := SurveyAsk(continueQs, &cont)
414+
if err != nil {
415+
return nil, err
416+
}
417+
418+
if !cont {
419+
return nil, nil
420+
}
421+
422+
for _, hunk := range hunks {
423+
fmt.Fprintf(out, "%s\n\n%s\n\n", hunk.File, hunk.Diff)
424+
fmt.Fprintln(out, "-----TODO-----")
425+
}
426+
427+
fmt.Fprintln(out)
428+
429+
return nil, nil
430+
}

0 commit comments

Comments
 (0)