Skip to content

Commit 266e8ea

Browse files
bug #858 Fixing missing blank line at end of modified patch files (weaverryan)
This PR was merged into the 1.x branch. Discussion ---------- Fixing missing blank line at end of modified patch files Fixes #856 tl;dr If a file has been modified in a recipe, but that file has been deleted in the user's project, we manually remove that file from that patch to avoid conflicts (and we report the patch to the user). There was a bug in that process that didn't guarantee an empty line at the end of the patch file. That made the patch file invalid for git. Thank you `@fbourigault` for the excellent bug report and reproducer! Commits ------- 65c7e8e Fixing missing blank line at end of modified patch files
2 parents 90ee9dd + 65c7e8e commit 266e8ea

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Update/DiffHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public static function removeFilesFromPatch(string $patch, array $files, array &
3535
$patch = $contentBefore.substr($patch, $end);
3636
}
3737

38+
// valid patches end with a blank line
39+
if ($patch && "\n" !== substr($patch, \strlen($patch) - 1, 1)) {
40+
$patch = $patch."\n";
41+
}
42+
3843
return $patch;
3944
}
4045
}

tests/Update/DiffHelperTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function getRemoveFilesFromPatchTests(): iterable
105105
+ dbal:
106106
+ # "TEST_TOKEN" is typically set by ParaTest
107107
+ dbname_suffix: '_test%env(default::TEST_TOKEN)%'
108+
108109
EOF
109110
, [
110111
'.env' => <<<EOF
@@ -154,6 +155,7 @@ public function getRemoveFilesFromPatchTests(): iterable
154155
+ dbal:
155156
+ # "TEST_TOKEN" is typically set by ParaTest
156157
+ dbname_suffix: '_test%env(default::TEST_TOKEN)%'
158+
157159
EOF
158160
, [
159161
'config/packages/doctrine.yaml' => <<<EOF
@@ -204,6 +206,7 @@ public function getRemoveFilesFromPatchTests(): iterable
204206
- type: pool
205207
- pool: doctrine.system_cache_pool
206208
query_cache_driver:
209+
207210
EOF
208211
, [
209212
'config/packages/test/doctrine.yaml' => <<<EOF
@@ -244,6 +247,7 @@ public function getRemoveFilesFromPatchTests(): iterable
244247
- type: pool
245248
- pool: doctrine.system_cache_pool
246249
query_cache_driver:
250+
247251
EOF
248252
, [
249253
'config/packages/test/doctrine.yaml' => <<<EOF

0 commit comments

Comments
 (0)