mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-28 08:20:56 +01:00
Fix some regexp issues for parsing SVN diffs with \r\n newlines
Summary: We need to tweak a few patterns to accommodate the possibility that lines end in "\r\n". Test Plan: Added failing unit test and made it pass. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran, mbishopim3 Maniphest Tasks: T1944 Differential Revision: https://secure.phabricator.com/D3772
This commit is contained in:
parent
6114d7cf9c
commit
10653d7ff3
3 changed files with 23 additions and 7 deletions
|
@ -649,7 +649,7 @@ final class ArcanistDiffParser {
|
|||
$line = $this->getLine();
|
||||
|
||||
if ($is_svn) {
|
||||
$ok = preg_match('/^=+$/', $line);
|
||||
$ok = preg_match('/^=+\s*$/', $line);
|
||||
if (!$ok) {
|
||||
$this->didFailParse("Expected '=======================' divider line.");
|
||||
} else {
|
||||
|
@ -684,8 +684,8 @@ final class ArcanistDiffParser {
|
|||
}
|
||||
|
||||
$is_binary_add = preg_match(
|
||||
'/^Cannot display: file marked as a binary type.$/',
|
||||
$line);
|
||||
'/^Cannot display: file marked as a binary type\.$/',
|
||||
rtrim($line));
|
||||
if ($is_binary_add) {
|
||||
$this->nextLine(); // Cannot display: file marked as a binary type.
|
||||
$this->nextNonemptyLine(); // svn:mime-type = application/octet-stream
|
||||
|
@ -697,7 +697,7 @@ final class ArcanistDiffParser {
|
|||
// WITHOUT a binary mime-type and is changed and given a binary mime-type.
|
||||
$is_binary_diff = preg_match(
|
||||
'/^Binary files .* and .* differ$/',
|
||||
$line);
|
||||
rtrim($line));
|
||||
if ($is_binary_diff) {
|
||||
$this->nextNonemptyLine(); // Binary files x and y differ
|
||||
$this->markBinary($change);
|
||||
|
@ -710,7 +710,7 @@ final class ArcanistDiffParser {
|
|||
// can not apply these patches.)
|
||||
$is_hg_binary_delete = preg_match(
|
||||
'/^Binary file .* has changed$/',
|
||||
$line);
|
||||
rtrim($line));
|
||||
if ($is_hg_binary_delete) {
|
||||
$this->nextNonemptyLine();
|
||||
$this->markBinary($change);
|
||||
|
@ -723,7 +723,7 @@ final class ArcanistDiffParser {
|
|||
// patch.
|
||||
$is_git_binary_patch = preg_match(
|
||||
'/^GIT binary patch$/',
|
||||
$line);
|
||||
rtrim($line));
|
||||
if ($is_git_binary_patch) {
|
||||
$this->nextLine();
|
||||
$this->parseGitBinaryPatch();
|
||||
|
@ -739,7 +739,7 @@ final class ArcanistDiffParser {
|
|||
|
||||
if ($is_git) {
|
||||
// "git diff -b" ignores whitespace, but has an empty hunk target
|
||||
if (preg_match('@^diff --git a/.*$@', $line)) {
|
||||
if (preg_match('@^diff --git .*$@', $line)) {
|
||||
$this->nextLine();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -549,6 +549,9 @@ EOTEXT
|
|||
'dst/file',
|
||||
$change->getCurrentPath());
|
||||
break;
|
||||
case 'more-newlines.svndiff':
|
||||
$this->assertEqual(1, count($changes));
|
||||
break;
|
||||
default:
|
||||
throw new Exception("No test block for diff file {$diff_file}.");
|
||||
break;
|
||||
|
|
13
src/parser/__tests__/diff/more-newlines.svndiff
Normal file
13
src/parser/__tests__/diff/more-newlines.svndiff
Normal file
|
@ -0,0 +1,13 @@
|
|||
Index: Database/tables/dbo.Account.sql
|
||||
===================================================================
|
||||
--- Database/tables/dbo.Account.sql (revision 1587)
|
||||
+++ Database/tables/dbo.Account.sql (working copy)
|
||||
@@ -23,6 +23,8 @@
|
||||
GO
|
||||
CREATE CLUSTERED INDEX IX_Account ON [Account] ([CreationDateTime])
|
||||
GO
|
||||
+ALTER TABLE [dbo].[Account] ADD CONSTRAINT [UK_Account_APIKey] UNIQUE ([APIKey])
|
||||
+GO
|
||||
ALTER TABLE [dbo].[Account] ADD CONSTRAINT [DF_Account_AccountId] DEFAULT (newid()) FOR [AccountId]
|
||||
GO
|
||||
ALTER TABLE [dbo].[Account] ADD CONSTRAINT [DF_Account_CreationDateTime] DEFAULT (getutcdate()) FOR [CreationDateTime]
|
Loading…
Reference in a new issue