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


Python Git.checkout方法代码示例

本文整理汇总了Python中git.cmd.Git.checkout方法的典型用法代码示例。如果您正苦于以下问题:Python Git.checkout方法的具体用法?Python Git.checkout怎么用?Python Git.checkout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.cmd.Git的用法示例。


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

示例1: roll

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import checkout [as 别名]
def roll(options, debug, info, error):
    to_arg = options.args.index('to')
    path = getcwd()
    git = Git(path)
    repo = Repo(path)

    dest = None
    source = None
    active = repo.active_branch
    settings = options.release_tool_settings

    if to_arg == 0:
        source = active
        dest = options.args[1]

        #update()
    elif to_arg == 1:
        source = options.args[0]
        dest = options.args[2]
    else:
        return

    secret = settings['secrets'][str(dest)]

    if secret:
        info('Special permission is required to roll to this branch.')

    if not secret or has_permission(if_matches=secret):
        debug('rebasing {source} onto {dest}...'.format(
            source=source,
            dest=dest
        ))

        if secret:
            debug(git.rebase(source, dest))
            git.tag('-m', message('Roll from {source} to {dest} with special \
permission by {name} <{email}>.'.format(
                    source=source,
                    dest=dest,
                    name=Actor.author().name,
                    email=Actor.author().email
                ), 'tag'),
                '-s',
                'roll-from-' +
                    source + '-to-' +
                    dest + '-' +
                    datetime.utcnow().isoformat().replace(':', '.'),
                output_stream=stdout)
        else:
            debug(git.rebase(source, dest))

        debug('checking out {source}...'.format(source=source))
        debug(git.checkout(active))

        info('Rolled {source} to {dest}.'.format(source=source, dest=dest))
    else:
        error('You do not have permission to roll to this branch')
开发者ID:Ponginae,项目名称:release-tool,代码行数:59,代码来源:pavement.py

示例2: createRelease

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import checkout [as 别名]
    def createRelease(self, name, parent=None):
        super(PuppetInstallMethod, self).createRelease(name, parent)

        with puppet_lock:
            # Move to concrete directory name
            orig_name = name
            name = name.replace("/", "@")

            # Clone repository
            cmd = Git(self.__work_path)
            if parent:
                if isinstance(parent, StringTypes):
                    parent = parent.replace("/", "@")
                else:
                    parent = parent.name.replace("/", "@")
                self.log.debug("cloning new git branch '%s' from '%s'"
                        % (name, parent))
                cmd.clone(self.__repo_path, name, b=parent)
            else:
                self.log.debug("creating new git branch '%s'" % name)
                cmd.clone(self.__repo_path, name)

            # Switch branch, add information
            cmd = Git(os.path.join(self.__work_path, name))
            host = self.env.id
            cmd.config("--global", "user.name", "GOsa management agent on %s" % host)
            self.log.debug("switching to newly created branch")
            cmd.checkout(b=name)

            # Remove refs if there's no parent
            current_dir = os.path.join(self.__work_path, name)
            if not parent:
                self.log.debug("no parent set - removing refs")
                cmd.symbolic_ref("HEAD", "refs/heads/newbranch")
                os.remove(os.path.join(current_dir, ".git", "index"))
                files = os.listdir(current_dir)

                # Remove all but .git
                for f in files:
                    if f== ".git":
                        continue
                    if os.path.isdir(f):
                        shutil.rmtree(os.path.join(current_dir, f))
                    else:
                        os.unlink(os.path.join(current_dir, f))

            # Create release info file
            self.log.debug("writing release info file in %s" % current_dir)
            with open(os.path.join(current_dir, "release.info"), "w") as f:
                now = datetime.now()
                f.write("Release: %s\n" % orig_name)
                f.write("Date: %s\n" % now.strftime("%Y-%m-%d %H:%M:%S"))

            self.log.debug("comitting new release")
            cmd.add("release.info")
            cmd.commit(m="Created release information")

            # Push to origin
            self.log.debug("pushing change to central repository")
            cmd.push("origin", name)

        return True
开发者ID:lhm-limux,项目名称:gosa,代码行数:64,代码来源:methods.py


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