def get_package_revision(package_name):
    # type: (str) -> str
    """Determine the Git commit hash for the Shopify package.

    If the package is installed in "develop" mode the SHA is retrieved using Git. Otherwise it will be retrieved from
    the package's Egg metadata. Returns an empty string if the package is not installed or does not contain revision
    information.
    """
    egg_info = pkg_resources.working_set.find(pkg_resources.Requirement.parse(package_name))
    if egg_info is None:
        return ''
    if os.path.exists(os.path.join(egg_info.location, '.git')):
        return str(subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=egg_info.location).decode()).strip()
    if egg_info.has_metadata('git_sha.txt'):
        return egg_info.get_metadata('git_sha.txt')

    return ''