Skip to content

parsePatch combines patches from multiple files into a single IUniDiff when there is no "Index" line #135

@ramya-rao-a

Description

@ramya-rao-a

parsePatch() in case of multiple files works well if the diff data for each file is preceeded by the "Index" line. In the absence of this "Index" line all patches are collapsed against the first file.

Since the "Index" line is optional, I would expect the below to work

Example: Pass the below diff string to parsePatch(). It is expected to return an array of 3 IUniDiff objects (each with 1 patch) for the 3 files. Instead it returns 1 IUniDiff object with 3 patches

--- C:\GoCode\src\github.com\golang\example\hello\hello.go 2016-09-14 14:38:47.780660100 -0700\r\n+++ C:\GoCode\src\github.com\golang\example\hello\hello.go.17760.renamed 2016-09-14 14:41:25.830187200 -0700\r\n@@ -14,6 +14,6 @@\r\n printMe123 := "!selpmaxe oG ,olleH"\r\n \r\n //sdsd\r\n- fmt.Println(stringutil.Reverse12(printMe123))\r\n+ fmt.Println(stringutil.Reverse1234(printMe123))\r\n \r\n }\r\n--- C:\GoCode\src\github.com\golang\example\stringutil\reverse.go 2016-09-13 20:14:42.643587100 -0700\r\n+++ C:\GoCode\src\github.com\golang\example\stringutil\reverse.go.17760.renamed 2016-09-14 14:41:25.865210500 -0700\r\n@@ -18,7 +18,7 @@\r\n package stringutil\r\n \r\n // Reverse returns its argument string reversed rune-wise left to right.\r\n-func Reverse12(s string) string {\r\n+func Reverse1234(s string) string {\r\n r := []rune(s)\r\n for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {\r\n r[i], r[j] = r[j], r[i]\r\n--- C:\GoCode\src\github.com\golang\example\stringutil\reverse_test.go 2016-09-13 20:14:43.883948400 -0700\r\n+++ C:\GoCode\src\github.com\golang\example\stringutil\reverse_test.go.17760.renamed 2016-09-14 14:41:25.895199900 -0700\r\n@@ -26,7 +26,7 @@\r\n {"Hello, 世界", "界世 ,olleH"},\r\n {"", ""},\r\n } {\r\n- got := Reverse12(c.in)\r\n+ got := Reverse1234(c.in)\r\n if got != c.want {\r\n t.Errorf("Reverse(%q) == %q, want %q", c.in, got, c.want)\r\n }\r\n"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions