From c0b03d0d34c2560f69c281e33ab352526f3532dc Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Mar 2017 14:09:27 +0100 Subject: [PATCH] Force exact tag checks when we are in a detached head state --- src/Composer/Package/Version/VersionGuesser.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index 011ac376d..bda0f7ec6 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -89,6 +89,7 @@ class VersionGuesser $commit = null; $version = null; $prettyVersion = null; + $isDetached = false; // try to fetch current version from git branch if (0 === $this->process->execute('git branch --no-color --no-abbrev -v', $output, $path)) { @@ -102,6 +103,7 @@ class VersionGuesser $version = 'dev-' . $match[2]; $prettyVersion = $version; $isFeatureBranch = true; + $isDetached = true; } else { $version = $this->versionParser->normalizeBranch($match[1]); $prettyVersion = 'dev-' . $match[1]; @@ -131,7 +133,7 @@ class VersionGuesser } } - if (!$version) { + if (!$version || $isDetached) { $result = $this->versionFromGitTags($path); if ($result) { $version = $result['version'];