public static function convertPackageVersion(PackageInterface $package, $fullReference = false)
    {
        $version = $package->getPrettyVersion();

        if ('dev' === $package->getStability()) {
            if (null === ($reference = $package->getDistReference())) {
                if (null === ($reference = $package->getSourceReference())) {
                    throw new \RuntimeException('Unable to determine reference for ' . $package->getPrettyName());
                }
            }

            $version .= '#' . (!$fullReference ? substr($reference, 0, 8) : $reference);
        }

        return $version;
    }