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


Python porcelain.commit方法代码示例

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


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

示例1: commit_and_push

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def commit_and_push(
    version: str,
    repository: Repository,
    paths: List[Path],
) -> None:
    """
    Commit and push all changes.
    """
    local_repository = Repo('.')
    _, ignored = add(paths=[str(path) for path in paths])
    assert not ignored
    message = b'Update for release ' + version.encode('utf-8')
    commit(message=message)
    branch_name = 'master'
    push(
        repo=local_repository,
        remote_location=repository.ssh_url,
        refspecs=branch_name.encode('utf-8'),
    ) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:21,代码来源:release.py

示例2: get_version

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def get_version(self):
        last_log = StringIO()

        # Get current branch
        current_branch = self.repo.refs.follow(b"HEAD")[0][1].decode().split("/")[-1]

        # Get last commit
        porcelain.log(self.repo, outstream=last_log, max_entries=1)

        commit_msg = last_log.getvalue()

        commit_match = re.search('commit: (.+?)\n', commit_msg)
        commit = commit_match.group(1) if commit_match else ""

        commit_match = re.search('Date: (.+?)\n\n', commit_msg)
        commit_date = commit_match.group(1).strip() if commit_match else ""

        commit_match = re.search("\n\n(.+?)\Z", commit_msg, flags=re.DOTALL)
        commit_info = commit_match.group(1).strip() if commit_match else ""

        return "I'm running commit `{}` of branch `{}`\n\n*{}*```{}```".format(commit, current_branch, commit_date, commit_info) 
开发者ID:OpenToAllCTF,项目名称:OTA-Challenge-Bot,代码行数:23,代码来源:githandler.py

示例3: upload

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def upload(self, cmd: str, meta: dict):
        """Push the current state of the registry to Git."""
        index = os.path.join(self.cached_repo, self.INDEX_FILE)
        if os.path.exists(index):
            os.remove(index)
        self._log.info("Writing the new index.json ...")
        with open(index, "w") as _out:
            json.dump(self.contents, _out, sort_keys=True, indent=4)
        git.add(self.cached_repo, [index])
        message = self.COMMIT_MESSAGES[cmd].format(**meta)
        if self.signoff:
            global_conf_path = os.path.expanduser("~/.gitconfig")
            if os.path.exists(global_conf_path):
                with open(global_conf_path, "br") as _in:
                    conf = ConfigFile.from_file(_in)
                    try:
                        name = conf.get(b"user", b"name").decode()
                        email = conf.get(b"user", b"email").decode()
                        message += self.DCO_MESSAGE.format(name=name, email=email)
                    except KeyError:
                        self._log.warning(
                            "Did not find name or email in %s, committing without DCO",
                            global_conf_path)
            else:
                self._log.warning("Global git configuration file %s does not exist, "
                                  "committing without DCO", global_conf_path)
        else:
            self._log.info("Committing the index without DCO")
        git.commit(self.cached_repo, message=message)
        self._log.info("Pushing the updated index ...")
        # TODO: change when https://github.com/dulwich/dulwich/issues/631 gets addressed
        git.push(self.cached_repo, self.remote_url, b"master")
        if self._are_local_and_remote_heads_different():
            self._log.error("Push has failed")
            raise ValueError("Push has failed") 
开发者ID:src-d,项目名称:modelforge,代码行数:37,代码来源:index.py

示例4: add_file

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def add_file(self, data, filename):
        """Add a file to the commit."""
        try:
            full_filename = os.path.join(self.repo_path, filename)

            with open(full_filename, "w") as f:
                f.write(data)

            porcelain.add(self.repo, full_filename)
        except Exception:
            # Anonymizing exceptions
            log.exception("GitHandler::add_file()")
            raise InvalidCommand("Adding file failed: Please check your log files...") 
开发者ID:OpenToAllCTF,项目名称:OTA-Challenge-Bot,代码行数:15,代码来源:githandler.py

示例5: commit

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def commit(self, commit_message):
        """Commit the current changeset."""
        try:
            porcelain.commit(self.repo, bytes(commit_message, "utf-8"))
        except Exception:
            # Anonymizing exceptions
            log.exception("GitHandler::commit()")
            raise InvalidCommand("Comitting file failed: Please check your log files...") 
开发者ID:OpenToAllCTF,项目名称:OTA-Challenge-Bot,代码行数:10,代码来源:githandler.py

示例6: push

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def push(self, repo_user, repo_pass, repo_remote, repo_branch):
        """Push the current commit to git."""
        try:
            porcelain.push(self.repo, "https://{}:{}@{}".format(repo_user,
                                                                repo_pass, repo_remote), bytes(repo_branch, "utf-8"))
        except dulwich.errors.GitProtocolError:
            raise InvalidCommand(
                "Upload file failed: GitProtocolError - Check your username and password in the git configuration...")
        except KeyError:
            raise InvalidCommand("Upload file failed: KeyError - Check your git configuration for missing keys...")
        except TypeError:
            raise InvalidCommand("Upload file failed: TypeError - Did you forget to create a git configuration?")
        except Exception:
            log.exception("GitHandler::push()")
            raise InvalidCommand("Upload file failed: Unknown - Please check your log files...") 
开发者ID:OpenToAllCTF,项目名称:OTA-Challenge-Bot,代码行数:17,代码来源:githandler.py

示例7: init_repo_if_empty

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def init_repo_if_empty(self,repo_name):
        repopath=os.path.join(self.view['repo'].base,repo_name)
        self.g= Gittle.init(repopath,bare=False )
        self.g.commit('name','email','initial commit')
        self.view['repo'].text=repo_name
        console.hud_alert('Repo {} created'.format(repo_name))
        self.did_select_repo(self.view['repo']) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:9,代码来源:gitui.py

示例8: commit

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def commit(self,sender):
        if list(itertools.chain(*porcelain.status(self.g.path).staged.itervalues())):
            self.g=self._get_repo()
            user=self.view['user'].text
            email=self.view['email'].text
            message=self.view['message'].text
            author = "{0} <{1}>".format(user, email)
            porcelain.commit(self.g.path,message,author,author)
            console.hud_alert('committed')
            self.view['message'].text=''
            self.refresh()
        else:
            console.hud_alert('nothing to commit!',icon='error') 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:15,代码来源:gitui.py

示例9: create_github_release

# 需要导入模块: from dulwich import porcelain [as 别名]
# 或者: from dulwich.porcelain import commit [as 别名]
def create_github_release(
    repository: Repository,
    version: str,
) -> None:
    """
    Create a tag and release on GitHub.
    """
    changelog_url = 'https://dcos-e2e.readthedocs.io/en/latest/changelog.html'
    release_name = 'Release ' + version
    release_message = 'See ' + changelog_url
    github_release = repository.create_git_tag_and_release(
        tag=version,
        tag_message='Release ' + version,
        release_name=release_name,
        release_message=release_message,
        type='commit',
        object=repository.get_commits()[0].sha,
        draft=False,
    )

    # The artifacts we build must be built from the tag we just created.
    # This tag is created remotely on GitHub using the GitHub HTTP API.
    #
    # We fetch all tags from GitHub and set our local HEAD to the latest master
    # from GitHub.
    #
    # One symptom of this is that ``minidcos --version`` from the PyInstaller
    # binary shows the correct version.
    local_repository = Repo('.')
    client = HttpGitClient(repository.owner.html_url)
    remote_refs = client.fetch(repository.name + '.git', local_repository)

    # Update the local tags and references with the remote ones.
    for key, value in remote_refs.items():
        local_repository.refs[key] = value

    # Advance local HEAD to remote master HEAD.
    local_repository[b'HEAD'] = remote_refs[b'refs/heads/master']

    # We need to make the artifacts just after creating a tag so that the
    # --version output is exactly the one of the tag.
    # No tag exists when the GitHub release is a draft.
    # This means that temporarily we have a release without binaries.
    linux_artifacts = make_linux_binaries(repo_root=Path('.'))
    for installer_path in linux_artifacts:
        github_release.upload_asset(
            path=str(installer_path),
            label=installer_path.name,
        ) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:51,代码来源:release.py


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