def get_push_src(repo, ref, tag):
    """
    Determine wether we can push the ref

    If the ref is further ahead than the tag
    we only want to push up to this tag.
    """
    commit = repo.rev_parse('%s^{commit}' % tag)
    if repo.rev_parse(ref) == commit:
        return ref
    else:
        return commit
