当前位置: 首页>>代码示例>>Python>>正文


Python cmd.git函数代码示例

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


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


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