git_options.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:origin-ci-tool 作者: openshift 项目源码 文件源码
def validate_git_specifier(refspec, branch, commit, tag):
    """
    Validate that the set of specifiers given is consistent.
    The set is valid if:
     - only a branch is given
     - only a commit is given
     - only a tag is given
     - a refspec and target non-master branch is given

    :param refspec: provided refspec like 'pull/1/head'
    :param branch: provided branch like 'master'
    :param commit: provided commit SHA like '2cbd73cbd5aacc965ecfa480fa90164a85191489'
    :param tag: provided tag like 'v1.3.0-rc2'
    """
    if commit and (refspec or branch or tag):
        raise UsageError('If a commit is specified, neither a refspec, branch, or tag can also be specified.')

    if tag and (commit or refspec or branch):
        raise UsageError('If a tag is specified, neither a refspec, branch, or commit can also be specified.')

    if refspec and not branch:
        raise UsageError('If a refspec is specified, the name of the branch to create for it is required.')

    if refspec and branch == 'master':
        raise UsageError('The branch specified for a refspec cannot be the master branch.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号