From 225a8f7a5660e12ad53298859a6674293cca3cb9 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 13 Oct 2014 16:17:28 -0300 Subject: [PATCH] Added branch-alias for dev-master to ```--version|-V``` output when current version is actually a revision (a non release/git tag). Example: Before: ``` $ composer --version Composer version 73e9db5d9952d52a46ecbc20a269a8c5f9c5b011 2014-10-07 15:03:19 ``` After: ``` $ composer --version Composer version 1.0-dev (73e9db5d9952d52a46ecbc20a269a8c5f9c5b011) 2014-10-07 15:03:19 ``` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Doc PR | none --- src/Composer/Compiler.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index 41c30d6d1..84dfec94d 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -12,6 +12,7 @@ namespace Composer; +use Composer\Json\JsonFile; use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; @@ -44,6 +45,14 @@ class Compiler } $this->version = trim($process->getOutput()); + $localConfig = __DIR__.'/../../composer.json'; + $file = new JsonFile($localConfig); + $localConfig = $file->read(); + + if (isset($localConfig['extra']['branch-alias']['dev-master'])) { + $this->version = sprintf('%s (%s)', $localConfig['extra']['branch-alias']['dev-master'], $this->version); + } + $process = new Process('git log -n1 --pretty=%ci HEAD', __DIR__); if ($process->run() != 0) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.');