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


Python Git.config方法代码示例

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


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

示例1: get_credentials

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import config [as 别名]
 def get_credentials(cls, repo=None):
     """
     Get credentials from the github.user and github.token config values
     """
     if repo:
         _git = repo.git
     else:
         _git = Git(os.getcwd())
     return cls(
         user=_git.config("github.user", with_exceptions=False),
         token=_git.config("github.token", with_exceptions=False),
     )
开发者ID:whitmo,项目名称:github-tools,代码行数:14,代码来源:gh_pages.py

示例2: get_credentials

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import config [as 别名]
 def get_credentials(cls, repo=None):
     """
     Get credentials from the github.user and github.token config values
     """
     if repo:
         _git = repo.git
     else:
         _git = Git(os.getcwd())
     return cls(
         user=_git.config('github.user'),
         token=_git.config('github.token')
         )
开发者ID:certik,项目名称:github-tools,代码行数:14,代码来源:gh_pages.py

示例3: GitWrapper

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import config [as 别名]

#.........这里部分代码省略.........
            cmd.wait()
        except GitCommandError as error:
            # Add more meta-information to errors
            message = "'{0}' returned exit status {1}".format(
                ' '.join(str(c) for c in error.command),
                error.status
            )

            raise GitError(message, stderr=error.stderr, stdout=stdout)

        return stdout.strip()

    def __getattr__(self, name):
        return lambda *args, **kwargs: self.run(name, *args, **kwargs)

    ###########################################################################
    # Overwrite some methods and add new ones
    ###########################################################################

    @contextmanager
    def stash(self):
        """
        A stashing contextmanager.
        It  stashes all changes inside and unstashed when done.
        """
        stashed = False

        if self.repo.is_dirty(submodules=False):
            if self.change_count > 1:
                message = 'stashing {0} changes'
            else:
                message = 'stashing {0} change'
            print(colored(
                message.format(self.change_count),
                'magenta'
            ))
            self.git.stash()
            stashed = True

        yield

        if stashed:
            print(colored('unstashing', 'magenta'))
            try:
                self.run('stash', 'pop')
            except GitError as e:
                raise UnstashError(stderr=e.stderr, stdout=e.stdout)

    def checkout(self, branch_name):
        """ Checkout a branch by name. """
        try:
            find(
                self.repo.branches, lambda b: b.name == branch_name
            ).checkout()
        except OrigCheckoutError as e:
            raise CheckoutError(branch_name, details=e)

    def rebase(self, target_branch):
        """ Rebase to target branch. """
        current_branch = self.repo.active_branch

        arguments = (
            ([self.config('git-up.rebase.arguments')] or []) +
            [target_branch.name]
        )
        try:
            self.run('rebase', *arguments)
        except GitError as e:
            raise RebaseError(current_branch.name, target_branch.name,
                              **e.__dict__)

    def config(self, key):
        """ Return `git config key` output or None. """
        try:
            return self.git.config(key)
        except GitCommandError:
            return None

    @property
    def change_count(self):
        """ The number of changes in the working directory. """
        status = self.git.status(porcelain=True, untracked_files='no').strip()
        if not status:
            return 0
        else:
            return len(status.split('\n'))

    @property
    def version(self):
        """
        Return git's version as a list of numbers.

        The original repo.git.version_info has problems with tome types of
        git version strings.
        """
        return re.search(r'\d+(\.\d+)+', self.git.version()).group(0)

    def is_version_min(self, required_version):
        """ Does git's version match the requirements? """
        return self.version.split('.') >= required_version.split('.')
开发者ID:Javex,项目名称:PyGitUp,代码行数:104,代码来源:git_wrapper.py


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