Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-03-06 20:00:15 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-03-06 20:57:56 +0300
commit66165edb02f0b40a6eaaf3a7137ff7f800fd0aea (patch)
tree01757fbe54916e693cc98148a51a7d9d4b2eb87c
parent511d532852a5df95649a39228b476ec638a487f9 (diff)
Drop using /dev/null as a diff path; it's not being used in the app
-rw-r--r--internal/diff/diff.go21
-rw-r--r--internal/service/diff/commit_test.go8
2 files changed, 14 insertions, 15 deletions
diff --git a/internal/diff/diff.go b/internal/diff/diff.go
index 6b17b4b75..fa223ae0d 100644
--- a/internal/diff/diff.go
+++ b/internal/diff/diff.go
@@ -34,7 +34,6 @@ type Parser struct {
var (
diffHeaderRegexp = regexp.MustCompile(`(?m)^diff --git a/(.*?) b/(.*?)$`)
indexHeaderRegexp = regexp.MustCompile(`(?m)^index ([[:xdigit:]]{40})..([[:xdigit:]]{40})(?:\s([[:digit:]]+))?$`)
- pathHeaderRegexp = regexp.MustCompile(`(?m)^([-+]){3} (?:[ab]/)?(.*?)$`)
renameCopyHeaderRegexp = regexp.MustCompile(`(?m)^(copy|rename) (from|to) (.*?)$`)
modeHeaderRegexp = regexp.MustCompile(`(?m)^(old|new|(?:deleted|new) file) mode (\d+)$`)
)
@@ -91,7 +90,7 @@ func (parser *Parser) Parse() bool {
parser.err = consumeChunkLine(parser.reader, parser.currentDiff)
} else if helper.ByteSliceHasAnyPrefix(line, "---", "+++") {
- parser.err = parseHeader(parser.reader, parser.currentDiff)
+ parser.err = consumeLine(parser.reader)
} else if helper.ByteSliceHasAnyPrefix(line, "-", "+", " ", "\\") {
parser.err = consumeChunkLine(parser.reader, parser.currentDiff)
} else {
@@ -143,15 +142,6 @@ func parseHeader(reader *bufio.Reader, diff *Diff) error {
}
}
- if matches := pathHeaderRegexp.FindSubmatch(line); len(matches) > 0 { // --- a/Makefile or +++ b/Makefile
- switch matches[1][0] {
- case '-':
- diff.FromPath = matches[2]
- case '+':
- diff.ToPath = matches[2]
- }
- }
-
if matches := renameCopyHeaderRegexp.FindSubmatch(line); len(matches) > 0 { // rename from cmd/gitaly-client/main.go
switch string(matches[2]) {
case "from":
@@ -200,3 +190,12 @@ func consumeBinaryNotice(reader *bufio.Reader, diff *Diff) error {
return nil
}
+
+func consumeLine(reader *bufio.Reader) error {
+ _, err := reader.ReadBytes('\n')
+ if err != nil && err != io.EOF {
+ return fmt.Errorf("ParseDiffOutput: Unexpected error while reading binary notice: %v", err)
+ }
+
+ return nil
+}
diff --git a/internal/service/diff/commit_test.go b/internal/service/diff/commit_test.go
index ffd9c4dda..3f3e50c86 100644
--- a/internal/service/diff/commit_test.go
+++ b/internal/service/diff/commit_test.go
@@ -46,7 +46,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
OldMode: 0100644,
NewMode: 0,
FromPath: []byte("gitaly/deleted-file"),
- ToPath: []byte("/dev/null"),
+ ToPath: []byte("gitaly/deleted-file"),
Binary: false,
},
ChunksCombined: testhelper.MustReadFile(t, "testdata/deleted-file-chunks.txt"),
@@ -104,7 +104,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
OldMode: 0100644,
NewMode: 0,
FromPath: []byte("gitaly/named-file-with-mods"),
- ToPath: []byte("/dev/null"),
+ ToPath: []byte("gitaly/named-file-with-mods"),
Binary: false,
},
ChunksCombined: testhelper.MustReadFile(t, "testdata/named-file-with-mods-chunks.txt"),
@@ -115,7 +115,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
ToID: "b464dff7a75ccc92fbd920fd9ae66a84b9d2bf94",
OldMode: 0,
NewMode: 0100644,
- FromPath: []byte("/dev/null"),
+ FromPath: []byte("gitaly/no-newline-at-the-end"),
ToPath: []byte("gitaly/no-newline-at-the-end"),
Binary: false,
},
@@ -138,7 +138,7 @@ func TestSuccessfulCommitDiffRequest(t *testing.T) {
ToID: "3856c00e9450a51a62096327167fc43d3be62eef",
OldMode: 0,
NewMode: 0100644,
- FromPath: []byte("/dev/null"),
+ FromPath: []byte("gitaly/renamed-file-with-mods"),
ToPath: []byte("gitaly/renamed-file-with-mods"),
Binary: false,
},