1
0
Fork 0

Return 7 chars and not 6 for short git hashes, formatting fixes

pull/1060/merge
Jordi Boggiano 2012-09-04 16:27:22 +02:00
parent 338730b19b
commit 0932f65a17
2 changed files with 21 additions and 8 deletions

View File

@ -76,7 +76,7 @@ class VersionParser
// if source reference is a sha1 hash -- truncate
if ($truncate && strlen($package->getSourceReference()) === 40) {
return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 6);
return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 7);
}
return $package->getPrettyVersion() . ' ' . $package->getSourceReference();

View File

@ -21,9 +21,6 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider formattedVersions
*
* @param \Composer\Package\PackageInterface $package
* @param string $expected
*/
public function testFormatVersionForDevPackage(PackageInterface $package, $truncate, $expected)
{
@ -33,10 +30,26 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
public function formattedVersions()
{
$data = array(
array('sourceReference' => 'v2.1.0-RC2', 'truncate' => true, 'expected' => 'PrettyVersion v2.1.0-RC2'),
array('sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77', 'truncate' => true, 'expected' => 'PrettyVersion bbf527'),
array('sourceReference' => 'v1.0.0', 'truncate' => false, 'expected' => 'PrettyVersion v1.0.0'),
array('sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77', 'truncate' => false, 'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'),
array(
'sourceReference' => 'v2.1.0-RC2',
'truncate' => true,
'expected' => 'PrettyVersion v2.1.0-RC2'
),
array(
'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
'truncate' => true,
'expected' => 'PrettyVersion bbf527a'
),
array(
'sourceReference' => 'v1.0.0',
'truncate' => false,
'expected' => 'PrettyVersion v1.0.0'
),
array(
'sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77',
'truncate' => false,
'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'
),
);
$self = $this;