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


Python git.checkout函数代码示例

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


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

示例1: cleanup_merge

        def cleanup_merge():
            git.checkout("master")
            # if something failed, the branch might still exist
            if self.gd.branch_exists("to_merge_1"):
                git.branch("-D", "to_merge_1")

            git.branch("-D", "base_branch")
开发者ID:infosucker,项目名称:api.opentreeoflife.org,代码行数:7,代码来源:test_gitdata.py

示例2: test_merge

    def test_merge(self):
        def cleanup_merge():
            git.checkout("master")
            # if something failed, the branch might still exist
            if self.gd.branch_exists("to_merge_1"):
                git.branch("-D", "to_merge_1")

            git.branch("-D", "base_branch")

        self.addCleanup(cleanup_merge)

        git.checkout("-b", "to_merge_1")
        git.checkout("-b", "base_branch")

        file = open("foo.txt", "w")
        file.write("ABC\n")
        file.close()

        git.add("foo.txt")

        git.commit("-m","Test commit")

        new_sha = self.gd.merge("to_merge_1", "base_branch")

        self.assertTrue( new_sha != "", "new_sha=%s is non-empty" % new_sha)
        self.assertEqual(len(new_sha), 40, "SHA is 40 chars")

        self.assertTrue(True, "Merge succeeded")
开发者ID:infosucker,项目名称:api.opentreeoflife.org,代码行数:28,代码来源:test_gitdata.py

示例3: _create_git

    def _create_git(self):
        """create a book from a git repo"""

        if not os.path.exists(self.path):
            LOG.info(("Creating book {0} from {1}, branch: {2}" +
                     "").format(self.path, self.git, self.branch))
            git.clone(self.git, self.path)
        else:
            LOG.info("Book {0} already exists".format(self.path))

        cwd = os.getcwd()
        os.chdir(self.path)

        if self.skiprepourlcheck:
            remote_match_found = False
            for remote in git("remote", "-v"):
                remote_parts = remote.split()

                if Url(remote_parts[1]) == Url(self.git):
                    remote_match_found = True

            if remote_match_found:
                LOG.debug('Found {0} in the list of remotes for {1}'.format(self.git, self.path))
            else:
                LOG.error('ERROR: {0} wasn\'t found in the list of remotes for {1}'.format(self.git, self.path))

        if not self._check_branch():
            LOG.info("Switching {0} to branch {1}".format(self.path,
                                                          self.branch))
            git.fetch
            git.checkout(self.branch)

        os.chdir(cwd)
开发者ID:gitshelf,项目名称:gitshelf,代码行数:33,代码来源:book.py

示例4: run

    def run(self):

        global _DEFAULT_PATH
        global _RESET_PATHS

        if 'path' in self.options:
            tut_path = self.options['path']
        elif _DEFAULT_PATH is not None:
            tut_path = _DEFAULT_PATH
        else:
            raise Exception("No tut path specified.")

        # paths are relative to the project root
        rel_path, tut_path = self.state.document.settings.env.relfn2path(
            tut_path)

        curdir = os.getcwd()
        os.chdir(tut_path)

        # if this is the first time visiting this repo
        if tut_path not in _RESET_PATHS:
            # record the current branch
            _RESET_PATHS[tut_path] = \
                git('name-rev', 'HEAD').strip().split()[-1]

        git.checkout(self.arguments[0].strip().lower())
        sphinx.pycode.ModuleAnalyzer.cache = {}

        os.chdir(curdir)

        return []
开发者ID:AnthonyTruchet,项目名称:tut,代码行数:31,代码来源:sphinx.py

示例5: create

def create(version_number):
    heading1("Creating new version based on Fedora " + version_number + "\n")

    # Update git and create new version.
    heading2("Updating master branch.")
    print(git.checkout("master"))
    print(git.pull())  # Bring branch current.

    heading2("Creating new branch")
    print(git.checkout("-b" + version_number))  # Create working branch.

    # Get kickstart files.
    heading2("Creating fedora-kickstarts directory\n")
    mkdir("-p", (base_dir + "/fedora-kickstarts/"))
    cd(base_dir + "/fedora-kickstarts/")

    heading2("Downloading Fedora kickstart files.")
    ks_base = "https://pagure.io/fedora-kickstarts/raw/f" \
              + version_number + "/f"

    for file in ks_files:
        file_path = ks_base + "/fedora-" + file

        print ("Downloading " + file_path)
        curl("-O", file_path)
开发者ID:RobbHendershot,项目名称:tananda-os-builder,代码行数:25,代码来源:tananda_os_builder.py

示例6: commit

    def commit(self, objects, message):
        # validate commit message
        if not message or not isinstance(message, basestring):
            raise ValueError("Commit message should not be empty or not string")

        env = os.environ.copy()
        env.update({
                'GIT_WORK_TREE': self.repo,
                'GIT_DIR': '%s/.git' % self.repo,
        })

        git.gc("--prune", _env=env)
        git.checkout("HEAD", _env=env)

        # pull and push from and to the remote
        git.pull("origin", "master", _env=env)

        for obj in objects:
            git.add("-A", obj, _env=env)

        try:
            git.commit("-m", message, _env=env)
        except Exception:
            pass

        git.push(_env=env)
开发者ID:Codevolve,项目名称:pyolite,代码行数:26,代码来源:git.py

示例7: newest_study_id

    def newest_study_id(self):
        "Return the numeric part of the newest study_id"
        os.chdir(self.repo)

        git.checkout("master")
        dirs = []
        # first we look for studies already in our master branch
        for f in os.listdir("study/"):
            if os.path.isdir("study/%s" % f):
                # ignore alphabetic prefix, o = created by opentree API
                if f[0].isalpha():
                    dirs.append(int(f[1:]))
                else:
                    dirs.append(int(f))

        # next we must look at local branch names for new studies
        # without --no-color we get terminal color codes in the branch output
        branches = git.branch("--no-color")
        branches = [ b.strip() for b in branches ]
        for b in branches:
            mo = re.match(".+_o(\d+)",b)
            if mo:
                dirs.append(int(mo.group(1)))

        dirs.sort()
        return dirs[-1]
开发者ID:infosucker,项目名称:api.opentreeoflife.org,代码行数:26,代码来源:gitdata.py

示例8: start

    def start(self, name, starting_point=None):
        """Start a new step (branch)."""

        # make sure this is not a known checkpoint
        if name in self.points():
            raise TutException("Duplicate checkpoint.")

        # make sure the repo is clean
        if self._repo_dirty():
            raise TutException("Dirty tree.")

        # create the new branch
        git.branch(name)

        if starting_point is None:
            args = ('-b', name)
        else:
            args = ('-b', name, starting_point, '--track')

        # add the branch to config
        config = self._config()
        points = config['points']
        if self.current():
            points.insert(points.index(self.current()) + 1, name)
        else:
            points.append(name)

        self._update_config(
            config,
            log='Adding new point %s' % name,
        )

        # checkout the new branch
        git.checkout(name)
开发者ID:austinvernsonger,项目名称:tut,代码行数:34,代码来源:model.py

示例9: publish_site

 def publish_site(self):
       tmp_branch = '__dynamo_deploy__'
       detached_branch = None
       
       git.checkout(self.target_branch)
       self._add_and_commit_site('dist')
       git.push('origin', self.target_branch)
       git.checkout('@{-1}')
开发者ID:Larusso,项目名称:xbmc-dynamo,代码行数:8,代码来源:publish.py

示例10: checkout

def checkout(branch):
    print "Checking out "+branch
    try:        
        git.checkout('-b',branch)
    except:
        # Branch already exists, check skip creation flag
        git.checkout(branch)
        pass
开发者ID:tim-kretschmer-c2fo,项目名称:ci-test,代码行数:8,代码来源:make_history.py

示例11: __init__

 def __init__(self, settings):
     self.settings = settings
     # Into the context
     if not os.path.exists(self.settings.local_dir):
         git.clone(self.settings.repo_url, self.settings.local_dir)
     cd(settings.local_dir)
     # Make sure checkout the right branch
     git.checkout(settings.branch)
     self.__current_commit = ""
开发者ID:WhiteIsClosing,项目名称:plib,代码行数:9,代码来源:ci.py

示例12: test_current_returns_none_on_unknown_branch

    def test_current_returns_none_on_unknown_branch(self):
        t = tut.model.Tut(self._testpath)
        t.init()
        t.start('step1')

        git.checkout('master')

        self.assertNotIn('master', t.points())
        self.assertEqual(t.current(), None)
开发者ID:austinvernsonger,项目名称:tut,代码行数:9,代码来源:test_model.py

示例13: install_addon

    def install_addon(self, addon):
        addonPath = os.path.join(self.get_addon_path(), addon.name)
        if os.path.isdir(addonPath):
            # Folder already exists
            if not os.path.isdir(os.path.join(addonPath, '.git')):
                raise Exception('WARNING',
                                'ALREADY_INSTALLED_UNLINKED',
                                'Addon %s is already installed, but it\'s state is unknown.\nPlease reinstall with:\n' % addon.name + note('ofx reinstall %s' % addon.name))
            else:
                os.chdir(addonPath)
                currentSha = sh.git('rev-parse', 'HEAD').rstrip()
                remoteSha = addon.latest_commit['sha']

                if addon.version is not None:
                    try:
                        git.checkout(addon.version)
                    except Exception:
                        raise Exception('ERROR',
                                        'UNKNOWN_VERSION',
                                        'No version named %s found for %s' % (addon.version, addon.name))

                    print ok() + addon.name + ": %s checked out" % addon.version
                else:
                    if currentSha == remoteSha:
                        raise Exception('OK',
                                        'ALREADY_INSTALLED',
                                        'Addon %s is already installed and up to date' % addon.name)
                    else:
                        raise Exception('WARNING',
                                        'ALREADY_INSTALLED_OUTDATED',
                                        'Addon %s is already installed but is not up to date. Consider running:\n' % addon.name + note("ofx update %s" % addon.name))
        else:
            print '>> Cloning %s' % addon.clone_url
            os.chdir(self.get_addon_path())
            git.clone(addon.clone_url)
            os.chdir(addonPath)

            sha = sh.git('rev-parse', 'HEAD').rstrip()
            if not sha:
                raise Exception('ERROR', 'CLONE_ERROR', "Something went wrong while cloning from "+addon.clone_url)
            else:
                print ok()+addon.name + ": Clone done"
                
                if addon.version is not None:
                    try:
                        git.checkout(addon.version)
                    except Exception:
                        raise Exception('ERROR',
                                        'UNKNOWN_VERSION',
                                        'No version named %s found for %s' % (addon.version, addon.name))

                    print ok() + addon.name + ": %s checked out" % addon.version

                self.install_dependencies(addon)
            return True
开发者ID:HalfdanJ,项目名称:ofx,代码行数:55,代码来源:ofx.py

示例14: cleanup

def cleanup(app, exception):

    global _RESET_PATHS

    curdir = os.getcwd()
    try:
        for path in _RESET_PATHS:
            os.chdir(path)
            git.checkout(_RESET_PATHS[path])
    finally:
        os.chdir(curdir)
开发者ID:austinvernsonger,项目名称:tut,代码行数:11,代码来源:sphinx.py

示例15: start

    def start(self, name):
        """Start a new step (branch)."""

        # make sure this is not a known checkpoint
        if name in self.points():
            raise TutException("Duplicate checkpoint.")

        # make sure the repo is clean
        if self._repo_dirty():
            raise TutException("Dirty tree.")

        git.checkout('-b', name)
开发者ID:AnthonyTruchet,项目名称:tut,代码行数:12,代码来源:model.py


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