Detect file header, when parsing Hunk#53
Merged
keegancsmith merged 1 commit intosourcegraph:masterfrom Aug 26, 2020
Merged
Conversation
keegancsmith
approved these changes
Aug 26, 2020
Member
|
Thanks! |
Contributor
|
Heads up: I think this commit broke some behaviour when parsing hunk lines that do contain Example diff: diff --git a/foobar.sql b/foobar.sql
index 55140ba..236cd59 100644
--- a/foobar.sql
+++ b/foobar.sql
@@ -1,4 +1,3 @@
select 1;
--- this is my query
select 2;
select 3;In SQL If I try to parse this with a new I'm currently investigating to see whether we can make that detect-file-header check more robust (maybe we need to read ahead and check whether the next line starts with |
mrnugget
added a commit
that referenced
this pull request
Sep 28, 2020
This fixes #54 by making the detection of non-extended file headers (which start with `---` directly) that was introduced in #53 more robust. Instead of simply aborting when the current line starts with `---` (which is a valid hunk line, if you, say, remove a line starting with `--`), we confirm that the next line also starts with `+++` by peeking a bit ahead. That's also what `git` does: https://sourcegraph.com/github.com/git/git/-/blob/apply.c#L1574-1576
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The version before was failing to identify next file header (without extended lines before it), while was parsing Hunk.
Hunk reader identify line as a part of the hunk, if it starts with
,+or-. Because of this, file header starting with---, was also identified as part of the hunk.