• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cmd.git函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rdopkg.utils.cmd.git函数的典型用法代码示例。如果您正苦于以下问题:Python git函数的具体用法?Python git怎么用?Python git使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了git函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update_branch_in_gerrit

def update_branch_in_gerrit(project, branch_name, commit_id):
    # assuming we're in the repo dir
    git('checkout', 'master')
    git('branch', '-f', branch_name, commit_id)
    git('checkout', branch_name)
    git('pull', 'origin', branch_name)
    git('push', 'origin', branch_name)
开发者ID:redhat-cip,项目名称:python-sfrdo,代码行数:7,代码来源:osreleases.py


示例2: get_updates_info

def get_updates_info(verbose=False):
    gitdir = tempfile.mkdtemp(prefix='rdopkg-list-updates')
    uinfos = []
    prev_cwd = os.getcwd()
    os.chdir(gitdir)
    try:
        cmd.git('init', log_cmd=False)
        f_project = filters.OrFilter()
        f_project.add_items('project', 'rdo-update')

        f_other = filters.Items()
        f_other.add_items('is', 'open')

        query = reviews.Query(cfg['RDO_UPDATE_GERRIT_HOST'])
        for review in query.filter(f_project, f_other):
            try:
                url = review.get('url', '???')
                if verbose:
                    log.info("Processing update review: %s" % url)
                uinfo = get_review_update_info(review, gitdir)
                uinfos.append(uinfo)
            except Exception as ex:
                if verbose:
                    log.warn("Error processing update review: %s: %s",
                             type(ex).__name__, str(ex))
                pass
    finally:
        os.chdir(prev_cwd)
        shutil.rmtree(gitdir)
    return uinfos
开发者ID:rootcanal,项目名称:rpmdistro-gitoverlay,代码行数:30,代码来源:reviews.py


示例3: add_patches

def add_patches(extra=False):
    git('checkout', 'master-patches')
    if extra:
        _do_patch('foofile', "#meh\n", 'Look, excluded patch')
        _do_patch('foofile', "#nope\n", 'Yet another excluded patch')
    _do_patch('foofile', "#huehue, change\n", 'Crazy first patch')
    _do_patch('foofile', "#lol, another change\n", 'Epic bugfix of doom MK2')
    git('checkout', 'master')
开发者ID:ktdreyer,项目名称:rdopkg,代码行数:8,代码来源:common.py


示例4: prep_patches_branch

def prep_patches_branch():
    git('checkout', '--orphan', 'master-patches')
    f = open('foofile', 'w')
    f.write("#not really a patch\n")
    f.close()
    git('add', 'foofile')
    git('commit', '-m', 'Create this test branch')
    git('tag', '1.2.3')
    git('checkout', 'master')
开发者ID:djipko,项目名称:rdopkg,代码行数:9,代码来源:common.py


示例5: _clone

    def _clone(self):
        if self.verbose:

            log.info("Cloning {desc} repo: {url}\n"
                     "        {space} into: {path}".format(
                         desc=self.repo_desc,
                         space=len(self.repo_desc) * ' ',
                         url=self.url,
                         path=self.repo_path))
        with helpers.cdir(self.base_path):
            cmd.git('clone', self.url, self.repo_name, log_cmd=self.verbose)
开发者ID:yac,项目名称:rdopkg,代码行数:11,代码来源:repoman.py


示例6: test_filter_out

def test_filter_out(tmpdir):
    dist_path = common.prep_spec_test(tmpdir, 'empty-ex-filter')
    with dist_path.as_cwd():
        common.prep_patches_branch()
        commit_before = git('rev-parse', 'HEAD')
        common.add_patches(extra=True, filtered=True)
        actions.update_patches('master',
                               local_patches_branch='master-patches',
                               version='1.2.3')
        commit_after = git('rev-parse', 'HEAD')
    common.assert_distgit(dist_path, 'patched-filter')
    assert commit_before != commit_after, "New commit not created"
开发者ID:djipko,项目名称:rdopkg,代码行数:12,代码来源:test_update_patches.py


示例7: get_review_update_info

def get_review_update_info(review, gitdir):
    url = review['url']
    patch_set = review['currentPatchSet']
    ref = patch_set['ref']
    uploader = patch_set['uploader']
    apprs = patch_set.get('approvals', [])
    authors = ["%s <%s>" % (uploader['name'], uploader['email'])]
    cmd.git('fetch', cfg['RDO_UPDATE_GERRIT_SSH'], ref, log_cmd=False)
    cmd.git('checkout', 'FETCH_HEAD', log_cmd=False)
    upf = rdoupdate.actions.get_last_commit_update('.')
    update = rdoupdate.actions.check_file(upf)
    uinfo = UpdateInfo(upf, update, authors, gerrit_url=url, gerrit_apprs=apprs)
    return uinfo
开发者ID:rootcanal,项目名称:rpmdistro-gitoverlay,代码行数:13,代码来源:reviews.py


示例8: add_patches

def add_patches(extra=False, filtered=False):
    git('checkout', 'master-patches')
    if extra:
        _do_patch('foofile', "#meh\n", 'Look, excluded patch')
        _do_patch('foofile', "#nope\n", 'Yet another excluded patch')
    _do_patch('foofile', "#huehue, change\n", 'Crazy first patch')
    if filtered:
        _do_patch('foofile', "#fix ci\n", 'DROP-IN-RPM: ci fix')
        _do_patch('foofile', "#and now for real\n", 'DROP-IN-RPM: moar ci fix')
    _do_patch('foofile', "#lol, another change\n", 'Epic bugfix of doom MK2')
    if filtered:
        _do_patch('foofile', "#oooops\n", 'DROP-IN-RPM: even moar ci fix')
    git('checkout', 'master')
开发者ID:djipko,项目名称:rdopkg,代码行数:13,代码来源:common.py


示例9: rebase_nightly

def rebase_nightly(upstream_branch, patches_branch, distgit_branch=None, lame_patches=None):
    spec = specfile.Spec()
    stable_tag, n_commits = spec.get_patches_base()

    if not distgit_branch:
        distgit_branch = git.current_branch()

    # tmp branches
    tmp_patches_branch = "tmp-" + patches_branch
    tmp_upstream_branch = "tmp-" + upstream_branch
    # nightly_parent serves to keep the parrent commit (patches_base)
    # everything will be rebased on top of it
    nightly_parent = "nightly-parent"

    # create the temporary branches
    git.create_branch(tmp_upstream_branch, upstream_branch)
    git.create_branch(tmp_patches_branch, patches_branch)

    git.checkout(tmp_upstream_branch)

    if lame_patches is not None:
        for commit in lame_patches:
            git.remove(commit)

    git.linearize(stable_tag)

    try:
        git.checkout(tmp_patches_branch)
        first_commit, last_commit = get_discarded_range(stable_tag, n_commits)
        # remove the discarded commits defined in the specfile from the
        # tmp patches branch
        if first_commit is not None:
            git("rebase", "--onto", first_commit + "^", last_commit, "--strategy", "recursive", "-X", "ours")
            git.create_branch(nightly_parent, last_commit)

        # add stable commits below downstream patches
        git("rebase", tmp_upstream_branch)

        if first_commit:
            # put everything on top of the commits that are discarded in
            # patches_base when running update-patches
            git("rebase", nightly_parent, "--strategy", "recursive", "-X", "theirs")

        # rebase tmp patches in the patches branch
        git.checkout(patches_branch)
        git("rebase", tmp_patches_branch)
    finally:
        git.delete_branch(tmp_upstream_branch)
        git.delete_branch(tmp_patches_branch)
        git.delete_branch(nightly_parent)
    git("checkout", distgit_branch)
开发者ID:rootcanal,项目名称:rpmdistro-gitoverlay,代码行数:51,代码来源:nightly.py


示例10: test_update_dense

def test_update_dense(tmpdir):
    dist_path = common.prep_spec_test(tmpdir, 'empty-dense')
    spec_path = dist_path.join('foo.spec')
    with dist_path.as_cwd():
        common.prep_patches_branch(dist_path)
        spec_before = spec_path.read()
        commit_before = git('rev-parse', 'HEAD')
        common.add_patches(extra=True)
        actions.update_patches('master',
                               local_patches_branch='master-patches',
                               version='1.2.3')
        spec_after = spec_path.read()
        commit_after = git('rev-parse', 'HEAD')
    common.assert_distgit(dist_path, 'patched-dense')
    assert commit_before != commit_after, "New commit not created"
开发者ID:kissthink,项目名称:rdopkg,代码行数:15,代码来源:test_update_patches.py


示例11: test_update_git_am_buildarch_fail

def test_update_git_am_buildarch_fail(tmpdir):
    dist_path = common.prep_spec_test(tmpdir, 'git-am-fail')
    spec_path = dist_path.join('foo.spec')
    with dist_path.as_cwd():
        common.prep_patches_branch(dist_path)
        spec_before = spec_path.read()
        commit_before = git('rev-parse', 'HEAD')
        common.add_patches(extra=True)
        with pytest.raises(rdopkg.utils.exception.BuildArchSanityCheckFailed):
            actions.update_patches('master',
                                   local_patches_branch='master-patches',
                                   version='1.2.3')
        spec_after = spec_path.read()
        commit_after = git('rev-parse', 'HEAD')
        apply_method = specfile.Spec().patches_apply_method()
    assert apply_method == 'git-am'
    assert commit_before == commit_after, "New commit created"
开发者ID:kissthink,项目名称:rdopkg,代码行数:17,代码来源:test_update_patches.py


示例12: git_check_remote

 def git_check_remote(self):
     assert(self.url)
     with self.repo_dir():
         remotes = cmd.git('remote', '-v', log_cmd=False)
     pattern = '^origin\s+%s\s+\(fetch\)$' % re.escape(self.url)
     if not re.search(pattern, remotes, re.MULTILINE):
         raise exception.RepoError(what="origin isn't set to expected URL: "
                                        "%s" % self.url)
开发者ID:yac,项目名称:rdopkg,代码行数:8,代码来源:repoman.py


示例13: test_update_autosetup

def test_update_autosetup(tmpdir):
    dist_path = common.prep_spec_test(tmpdir, 'autosetup')
    spec_path = dist_path.join('foo.spec')
    with dist_path.as_cwd():
        common.prep_patches_branch(dist_path)
        spec_before = spec_path.read()
        commit_before = git('rev-parse', 'HEAD')
        common.add_patches(extra=True)
        actions.update_patches('master',
                               local_patches_branch='master-patches',
                               version='1.2.3')
        spec_after = spec_path.read()
        commit_after = git('rev-parse', 'HEAD')
        apply_method = specfile.Spec().patches_apply_method()
    assert apply_method == 'autosetup'
    common.assert_distgit(dist_path, 'patched-autosetup')
    assert commit_before != commit_after, "New commit not created"
开发者ID:kissthink,项目名称:rdopkg,代码行数:17,代码来源:test_update_patches.py


示例14: _push_pkg

        def _push_pkg(upf):
            log.info("\nPushing update {t.bold}{upf}{t.normal}".format(
                t=log.term, upf=upf))
            update = self._load_update_file(upf)
            pushed_rpms = []
            try:
                _updated_repos = set()
                _updated_repo_bases = set()
                _pushed_build_tmp_paths = []
                for build in update.builds:
                    src_path = self._build_tmp_path(upf, build)
                    if src_path in _pushed_build_tmp_paths:
                        continue
                    build_rpms = helpers.find_files(src_path, ext='.rpm')
                    dest_repo_base_path = self._dest_repo_base_path(build.repo)
                    if not os.path.isdir(dest_repo_base_path):
                        raise exception.NotADirectory(path=dest_repo_base_path)
                    dest_path = self._build_dest_path(build)
                    for rpm in build_rpms:
                        pushed_path = copy_package(rpm, dest_path,
                                                   overwrite=self.overwrite)
                        pushed_rpms.append(pushed_path)
                    _pushed_build_tmp_paths.append(src_path)
                    _updated_repo_bases.add(dest_repo_base_path)
                    _updated_repos.add(self._dest_repo_path(build.repo,
                                                            build.dist))

                with helpers.cdir(self.update_repo_path):
                    helpers.ensure_dir(self.pushed_dir)
                    upf_base = os.path.basename(upf)
                    pushed_upf = os.path.join(self.pushed_dir, upf_base)
                    pushed_files_fn = pushed_upf + self.pushed_files_ext
                    git('mv', upf, pushed_upf)
                    pushed_files_f = open(pushed_files_fn, 'w')
                    pushed_files_f.writelines(
                        map(lambda x: "%s\n" % x, pushed_rpms))
                    pushed_files_f.close()
                    git('add', pushed_files_fn)
                    try:
                        git('commit', '-m',
                            "Push %s" % rdoupdate.core.pp_update(upf))
                    except Exception:
                        git('git', 'reset', '--hard')
                        raise
                updated_repos.update(_updated_repos)
                updated_repo_bases.update(_updated_repo_bases)
            except Exception as ex:
                if pushed_rpms:
                    log.warn("Final push failed for %s, cleaning copied "
                             "packages" % upf)
                    for rpm in pushed_rpms:
                        log.info("{t.warn}remove{t.normal} {rpm}".format(
                            t=log.term, rpm=rpm))
                        os.remove(rpm)
                raise
开发者ID:djipko,项目名称:rdopkg,代码行数:55,代码来源:pushupdate.py


示例15: test_update_noop

def test_update_noop(tmpdir):
    dist_path = common.prep_spec_test(tmpdir, 'patched')
    spec_path = dist_path.join('foo.spec')
    with dist_path.as_cwd():
        common.prep_patches_branch(dist_path)
        spec_before = spec_path.read()
        common.add_patches()
        actions.update_patches('master',
                               local_patches_branch='master-patches',
                               version='1.2.3')
        spec_after = spec_path.read()
        assert spec_after == spec_before
        commit_before = git('rev-parse', 'HEAD')
        actions.update_patches('master',
                               local_patches_branch='master-patches',
                               version='1.2.3')
        commit_after = git('rev-parse', 'HEAD')
    assert commit_before == commit_after, "Commit created for no-op"
开发者ID:kissthink,项目名称:rdopkg,代码行数:18,代码来源:test_update_patches.py


示例16: fetch_patches_branch

def fetch_patches_branch(local_patches_branch, gerrit_patches_chain,
                         force=False):
    review_n = _review_number(gerrit_patches_chain)
    gerrit_host, gerrit_port = guess.gerrit_from_repo()
    query = GerritQuery(gerrit_host, gerrit_port)
    review = query('--current-patch-set', review_n)
    current_ps = review.get('currentPatchSet', {})
    patchset_n = current_ps.get('number')
    if not patchset_n:
        raise exception.CantGuess(
            msg='Failed to determine current patch set for review: %s'
                % gerrit_patches_chain)
    gerrit_ref = _review_ref(review_n, patchset_n)
    git('fetch', 'patches', gerrit_ref)

    approvals = current_ps.get('approvals', [])
    jenkins = [a for a in approvals
               if a.get('type') == 'Verified' and
               a.get('by', {}).get('username') == 'jenkins']
    code_reviews = [int(a.get('Value', 0)) for a in approvals
                    if a.get('type') == 'Code-Review']
    if not jenkins:
        verified = 0
    else:
        verified = int(jenkins[0]['value'])
    if verified != 1:
        if force:
            log.warn(
                "Ref %s has not been validated by CI." % gerrit_patches_chain)
            helpers.confirm("Do you want to continue anyway?",
                            default_yes=False)
        else:
            raise exception.UnverifiedPatch()
    if any(cr < 0 for cr in code_reviews):
        log.warn(
            "Ref %s has at least one negative review." % gerrit_patches_chain)
        helpers.confirm("Do you want to continue anyway?",
                        default_yes=False)

    git('update-ref', 'refs/heads/%s' % local_patches_branch,
        'FETCH_HEAD')
开发者ID:yac,项目名称:rdopkg,代码行数:41,代码来源:rpmfactory.py


示例17: prep_spec_test

def prep_spec_test(tmpdir, distgit):
    dist_path = tmpdir.join('dist')
    shutil.copytree(os.path.join(ASSETS_DIR, 'spec', distgit),
                    str(dist_path))
    with dist_path.as_cwd():
        git('init')
        git('add', '.')
        git('commit', '-m', 'Initial import')
    return dist_path
开发者ID:djipko,项目名称:rdopkg,代码行数:9,代码来源:common.py


示例18: prep_push_test

def prep_push_test(tmpdir, update_repo, dest):
    rdoup_path = tmpdir.join('rdo-update')
    dest_path = tmpdir.join('dest')
    shutil.copytree(os.path.join(ASSETS_DIR, 'rdo-update.git', update_repo),
                    str(rdoup_path))
    shutil.copytree(os.path.join(ASSETS_DIR, 'dest', dest), str(dest_path))
    with rdoup_path.as_cwd():
        git('init')
        git('add', '.')
        git('commit', '-m', 'Initial import')
    return rdoup_path, dest_path
开发者ID:djipko,项目名称:rdopkg,代码行数:11,代码来源:test_push_update.py


示例19: _fetch

 def _fetch(self, force=False):
     need_fetch = True
     with self.repo_dir():
         if not force:
             try:
                 t_fetch = os.path.getmtime('.git/FETCH_HEAD')
                 t_now = int(time.time())
                 delta = t_now - t_fetch
                 if delta < cfg['FETCH_PERIOD']:
                     need_fetch = False
             except Exception:
                 pass
         if need_fetch:
             if self.verbose:
                 log.info("Fetching %s repo: %s" % (
                     self.repo_desc, self.repo_path))
             cmd.git('fetch', 'origin', log_cmd=self.verbose)
             cmd.git('checkout', '-f', 'master', log_cmd=self.verbose)
             cmd.git('reset', '--hard', 'origin/master',
                     log_cmd=self.verbose)
开发者ID:yac,项目名称:rdopkg,代码行数:20,代码来源:repoman.py


示例20: review

 def review(self):
     with self.repo_dir():
         with helpers.setenv(USERNAME=self.user):
             cmd.git('review', direct=True)
开发者ID:yac,项目名称:rdopkg,代码行数:4,代码来源:repoman.py



注:本文中的rdopkg.utils.cmd.git函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.info函数代码示例发布时间:2022-05-26
下一篇:
Python cPickle.loads函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap