Przeglądaj źródła

Make sure a lock file is always written and things work well even without any dependencies in the require/require-dev

Jordi Boggiano 5 lat temu
rodzic
commit
292d4b3c8f

+ 0 - 12
src/Composer/Package/Locker.php

@@ -345,18 +345,6 @@ class Locker
             $lock['platform-overrides'] = $platformOverrides;
         }
 
-        if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) {
-            if ($this->lockFile->exists()) {
-                if ($write) {
-                    unlink($this->lockFile->getPath());
-                } else {
-                    $this->virtualFileWritten = false;
-                }
-            }
-
-            return false;
-        }
-
         try {
             $isLocked = $this->isLocked();
         } catch (ParsingException $e) {

+ 20 - 0
tests/Composer/Test/Fixtures/installer/update-to-empty-from-blank.test

@@ -0,0 +1,20 @@
+--TEST--
+Update to a state without dependency works well from a blank slate
+--COMPOSER--
+{
+}
+--RUN--
+update
+--EXPECT-LOCK--
+{
+    "packages": [],
+    "packages-dev": [],
+    "aliases": [],
+    "minimum-stability": "stable",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": [],
+    "platform-dev": []
+}
+--EXPECT--

+ 47 - 0
tests/Composer/Test/Fixtures/installer/update-to-empty-from-locked.test

@@ -0,0 +1,47 @@
+--TEST--
+Update to a state without dependency works well from locked with dependency
+--COMPOSER--
+{
+    "minimum-stability": "dev"
+}
+--INSTALLED--
+[
+    {
+        "name": "a/a", "version": "dev-master",
+        "source": { "reference": "1234", "type": "git", "url": "" }
+    }
+]
+--LOCK--
+{
+    "packages": [
+        {
+            "name": "a/a", "version": "dev-master",
+            "source": { "reference": "1234", "type": "git", "url": "" },
+            "type": "library"
+        }
+    ],
+    "packages-dev": [],
+    "aliases": [],
+    "minimum-stability": "dev",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": [],
+    "platform-dev": []
+}
+--RUN--
+update
+--EXPECT-LOCK--
+{
+    "packages": [],
+    "packages-dev": [],
+    "aliases": [],
+    "minimum-stability": "dev",
+    "stability-flags": [],
+    "prefer-stable": false,
+    "prefer-lowest": false,
+    "platform": [],
+    "platform-dev": []
+}
+--EXPECT--
+Uninstalling a/a (dev-master 1234)