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


Python git.Git方法代码示例

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


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

示例1: print_git_commit

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def print_git_commit():
    """
    Print the current git commit of ParlAI and parlai_internal.
    """
    root = os.path.dirname(os.path.dirname(parlai.__file__))
    internal_root = os.path.join(root, 'parlai_internal')
    try:
        git_ = git.Git(root)
        current_commit = git_.rev_parse('HEAD')
        logging.info(f'Current ParlAI commit: {current_commit}')
    except git.GitCommandNotFound:
        pass
    except git.GitCommandError:
        pass

    try:
        git_ = git.Git(internal_root)
        internal_commit = git_.rev_parse('HEAD')
        logging.info(f'Current internal commit: {internal_commit}')
    except git.GitCommandNotFound:
        pass
    except git.GitCommandError:
        pass 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:25,代码来源:params.py

示例2: print_git_commit

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def print_git_commit():
    """Print the current git commit of ParlAI and parlai_internal."""
    root = os.path.dirname(os.path.dirname(parlai.__file__))
    internal_root = os.path.join(root, 'parlai_internal')
    try:
        git_ = git.Git(root)
        current_commit = git_.rev_parse('HEAD')
        print(f'[ Current ParlAI commit: {current_commit} ]')
    except git.GitCommandNotFound:
        pass
    except git.GitCommandError:
        pass

    try:
        git_ = git.Git(internal_root)
        internal_commit = git_.rev_parse('HEAD')
        print(f'[ Current internal commit: {internal_commit} ]')
    except git.GitCommandNotFound:
        pass 
开发者ID:natashamjaques,项目名称:neural_chat,代码行数:21,代码来源:params.py

示例3: create_pr_message

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def create_pr_message(self, skill_git: Git, skill_repo: Repository) -> tuple:
        """Reads git commits from skill repo to create a list of changes as the PR content"""
        title = 'Upgrade ' + self.skill.name
        body = body_template.format(
            skill_name=self.skill.name,
            commits='\n'.join(
                ' - [{}]({})'.format(
                    skill_git.show('-s', sha, format='%s'),
                    skill_repo.get_commit(sha).html_url
                )
                for sha in skill_git.rev_list(
                    '--ancestry-path', '{}..{}'.format(self.skill.entry.sha, 'HEAD')
                ).split('\n')
            )
        )
        return title, body 
开发者ID:MycroftAI,项目名称:mycroft-skills-kit,代码行数:18,代码来源:upgrade.py

示例4: link_github_repo

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def link_github_repo(self, get_repo_name: Callable = None) -> Optional[Repository]:
        if 'origin' not in Git(self.path).remote().split('\n'):
            if ask_yes_no(
                    'Would you like to link an existing GitHub repo to it? (Y/n)',
                    True):
                repo_name = (get_repo_name and get_repo_name()) or (
                        self.name + '-skill')
                repo = self.user.get_repo(repo_name)
                self.git.remote('add', 'origin', repo.html_url)
                self.git.fetch()
                try:
                    self.git.pull('origin', 'master')
                except GitCommandError as e:
                    if e.status == 128:
                        raise UnrelatedGithubHistory(repo_name) from e
                    raise
                self.git.push('origin', 'master', set_upstream=True)
                print('Linked and pushed to GitHub repo:', repo.html_url)
                return repo 
开发者ID:MycroftAI,项目名称:mycroft-skills-kit,代码行数:21,代码来源:create.py

示例5: DownloadAMDVLKComponents

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def DownloadAMDVLKComponents(self):
        os.chdir(self.srcDir);

        for i in self.components:
            if not os.path.exists(self.srcDir + i):
                print("Downloading " + i + ".....");
                git.Git().clone(self.targetRepo + i);

            repo = git.Repo(i);
            repo.git.clean('-xdf');
            # Clean the submodule
            repo.git.clean('-xdff');
            if (i == 'llvm-project'):
                repo.git.checkout('remotes/origin/amd-gfx-gpuopen-' + self.branch, B='amd-gfx-gpuopen-' + self.branch);
            elif (i == 'MetroHash' or i == 'CWPack'):
                repo.git.checkout('remotes/origin/amd-master', B='amd-master');
            else:
                repo.git.checkout('remotes/origin/' + self.branch, B=self.branch);
            repo.git.pull(); 
开发者ID:GPUOpen-Drivers,项目名称:AMDVLK,代码行数:21,代码来源:amdvlk_build_deb_from_tag.py

示例6: go_to_root

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def go_to_root(fn):
    """
    Decorator which will execute the decorated function at the root
    of the git hierarchy. It returns to the old directory after
    executing the function
    """

    def wrapped(squadron_dir, *args, **kwargs):
        old_cwd = os.getcwd()
        try:
            if squadron_dir == os.getcwd():
                # We might not be at the root
                root_dir = Git(squadron_dir).rev_parse('--show-toplevel')

                os.chdir(root_dir)
                squadron_dir = root_dir
            return fn(squadron_dir, *args, **kwargs)
        finally:
            os.chdir(old_cwd)
    return wrapped 
开发者ID:gosquadron,项目名称:squadron,代码行数:22,代码来源:gotoroot.py

示例7: login_github

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def login_github():
    git = Git()
    
    for i in range(3):
        user_id = input('* GitHub id: ')
        user_password = getpass.getpass('* GitHub password: ')

        error, result = git.login_github(user_id, user_password)
        if error:
            print(PRINT_FORMAT % (result))
            continue

        print(PRINT_FORMAT % (result))
        repo_name = input('* Repository: ')
        git.set_repository(repo_name)
        return git
    
    sys.exit(ERROR_FORMAT % ('login_github', 'Login failed')) 
开发者ID:ISKU,项目名称:BOJ-AutoCommit,代码行数:20,代码来源:main.py

示例8: __init__

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def __init__(self, git_uri, window):
        self._window = window
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()

        self._builder.add_from_resource('/com/nautilus/git/ui/location.ui')
        self._builder.connect_signals({
            "open_remote_clicked": self._open_remote_browser,
            "compare_commits_clicked": self._compare_commits,
            "popover_clicked": self._trigger_popover,
            "branch_clicked": self._update_branch
        })
        self._build_widgets() 
开发者ID:bilelmoussaoui,项目名称:nautilus-git,代码行数:18,代码来源:location.py

示例9: __init__

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def __init__(self, path: str, conf=None):
        """
        Init the Git RepositoryMining.

        :param str path: path to the repository
        """
        self.path = Path(path)
        self.project_name = self.path.name
        self.lock = Lock()
        self._git = None
        self._repo = None

        # if no configuration is passed, then creates a new "emtpy" one
        # with just "path_to_repo" inside.
        if conf is None:
            conf = Conf({
                "path_to_repo": str(self.path),
                "git_repo": self
            })

        self._conf = conf
        self._conf.set_value("main_branch", None)  # init main_branch to None 
开发者ID:ishepard,项目名称:pydriller,代码行数:24,代码来源:git_repository.py

示例10: checkout_git_tag

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def checkout_git_tag(repo_dir, tag):
    import git
    exe = which("git")
    if not exe:
        raise Exception("git executable not found")
    repo = git.Git(repo_dir)
    try:
        repo.checkout(tag)
    except Exception as e:
        print ("failed to checkout tag %s of repo %s, error is %s" % (tag, repo_dir, str(e)))
        return False
    return True 
开发者ID:osssanitizer,项目名称:osspolice,代码行数:14,代码来源:utils.py

示例11: get_git_log

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def get_git_log(repo_dir, fmt='--pretty=%ct', count=1):
    import git
    exe = which("git")
    if not exe:
        raise Exception("git executable not found")
    repo = git.Git(repo_dir)
    return repo.log(fmt, '-n', count) 
开发者ID:osssanitizer,项目名称:osspolice,代码行数:9,代码来源:utils.py

示例12: clone_repo

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def clone_repo(self, repo_name, repo_url, repo_path, branch=None):
        attempts = self.__retries
        while attempts:
            try:
                import git
                logger.info("cloning repo %s branch %s into %s (attempt %s timeout %s)",
                            repo_name, branch, repo_path, self.__retries - attempts, self.__timeout)

                # register timeout handler
                with utils.time_limit(self.__timeout):
                    if branch:
                        git.Git().clone(repo_url, repo_path, depth=1, branch=branch)
                    else:
                        git.Git().clone(repo_url, repo_path, depth=1)

                    return repo_name

            # timed out
            except utils.TimeoutException as te:
                logger.error("Repo clone for %s %s", repo_name, str(te))
                attempts -= 1
                if os.path.isdir(repo_path):
                    shutil.rmtree(repo_path)
                # try again
                continue

            except Exception as e:
                logger.error("Failed to clone repo %s: %s", repo_name, str(e))
                return None

        logger.error("Giving up on cloning github repo %s!", repo_name)
        return None 
开发者ID:osssanitizer,项目名称:osspolice,代码行数:34,代码来源:github.py

示例13: read_template_manifest

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def read_template_manifest(folder, checkout=False):
    """Extract template metadata from the manifest file.

    :param folder: path where to find the template manifest file
    :param checkout: checkout the template folder from local repo
    """
    manifest_path = folder / TEMPLATE_MANIFEST
    try:
        manifest = yaml.safe_load(manifest_path.read_text())
    except FileNotFoundError as e:
        raise errors.InvalidTemplateError(
            'There is no manifest file "{0}"'.format(TEMPLATE_MANIFEST)
        ) from e
    validate_template_manifest(manifest)

    if checkout:
        git_repo = git.Git(str(folder))
        template_folders = [template['folder'] for template in manifest]
        if len(template_folders) < 1:
            raise errors.InvalidTemplateError(
                'Cannot find any valid template in manifest file'
            )
        for template_folder in template_folders:
            template_path = folder / template_folder
            try:
                git_repo.checkout(template_folder)
            except git.exc.GitCommandError as e:
                raise errors.InvalidTemplateError(
                    'Cannot checkout the folder "{0}"'.format(template_folder)
                ) from e
            validate_template(template_path)

    return manifest 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:35,代码来源:init.py

示例14: linkcode_resolve

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def linkcode_resolve(domain, info):
    # Resolve function for the linkcode extension.
    # Stolen shamelessly from Lasagne! Thanks Lasagne!
    # https://github.com/Lasagne/Lasagne/blob/5d3c63cb315c50b1cbd27a6bc8664b406f34dd99/docs/conf.py#L114-L135
    def find_source():
        # try to find the file and line number, based on code from numpy:
        # https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
        obj = sys.modules[info['module']]
        for part in info['fullname'].split('.'):
            obj = getattr(obj, part)
        import inspect
        import os

        fn = inspect.getsourcefile(obj)
        fn = os.path.relpath(fn, start=os.path.dirname(parlai.__file__))
        source, lineno = inspect.getsourcelines(obj)
        return fn, lineno, lineno + len(source) - 1

    if domain != 'py' or not info['module']:
        return None
    try:
        filename = 'parlai/%s#L%d-L%d' % find_source()
        tag = git.Git().rev_parse('HEAD')
        return "https://github.com/facebookresearch/ParlAI/blob/%s/%s" % (tag, filename)
    except Exception:
        return None


# At the bottom of conf.py 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:31,代码来源:conf.py

示例15: download_yara_rules_git

# 需要导入模块: import git [as 别名]
# 或者: from git import Git [as 别名]
def download_yara_rules_git():
    git.Git().clone("https://github.com/Yara-Rules/rules") 
开发者ID:secrary,项目名称:SSMA,代码行数:4,代码来源:check_updates.py


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