def get_gitref(repo, ref):
    """
    Retrieve git repo reference if available.
    """
    try:
        return repo.commit(ref)
    except (BadName, BadObject):
        return False

    Retrieve git repo reference if available.
    
st2common/st2common/util/pack_management.py