Browse Source

Skip parsing equal branches/tags to avoid failures in packagist down the line

Jordi Boggiano 7 years ago
parent
commit
4d8b9be5b6
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/Composer/Repository/VcsRepository.php

+ 16 - 1
src/Composer/Repository/VcsRepository.php

@@ -188,6 +188,13 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
                     continue;
                 }
 
+                if ($existingPackage = $this->findPackage($data['name'], $data['version_normalized'])) {
+                    if ($verbose) {
+                        $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
+                    }
+                    continue;
+                }
+
                 if ($verbose) {
                     $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
                 }
@@ -205,7 +212,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
             $this->io->overwriteError('', false);
         }
 
-        foreach ($driver->getBranches() as $branch => $identifier) {
+        $branches = $driver->getBranches();
+        foreach ($branches as $branch => $identifier) {
             $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
             if ($verbose) {
                 $this->io->writeError($msg);
@@ -213,6 +221,13 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
                 $this->io->overwriteError($msg, false);
             }
 
+            if ($branch === 'trunk' && isset($branches['master'])) {
+                if ($verbose) {
+                    $this->io->writeError('<warning>Skipped branch '.$branch.', can not parse both master and trunk branches as they both resolve to 9999999-dev internally</warning>');
+                }
+                continue;
+            }
+
             if (!$parsedBranch = $this->validateBranch($branch)) {
                 if ($verbose) {
                     $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');