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


Python repo.Repo方法代码示例

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


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

示例1: get_version

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def get_version() -> str:
    """
    Return the next version.
    This is today’s date in the format ``YYYY.MM.DD.MICRO``.
    ``MICRO`` refers to the number of releases created on this date,
    starting from ``0``.
    """
    utc_now = datetime.datetime.utcnow()
    date_format = '%Y.%m.%d'
    date_str = utc_now.strftime(date_format)
    local_repository = Repo('.')
    tag_labels = tag_list(repo=local_repository)
    tag_labels = [item.decode() for item in tag_labels]
    today_tag_labels = [
        item for item in tag_labels if item.startswith(date_str)
    ]
    micro = int(len(today_tag_labels))
    return '{date}.{micro}'.format(date=date_str, micro=micro) 
开发者ID:dcos,项目名称:dcos-e2e,代码行数:20,代码来源:release.py

示例2: commit_and_push

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [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

示例3: find_lost_commits

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def find_lost_commits():
	r=Repo('.')
	o=r.object_store
	
	all_commits=[]
	all_trees=[]
	for sha in o:
		obj=o[sha]
		if isinstance(obj,Commit):
			all_commits.append(obj)
	
	#hide commits that have children, so we get "ends" of chains only
	for c in all_commits:
		for p in c.parents:
			try:
				all_commits.remove(p)
			except ValueError:
				pass
		if c.sha in r.get_refs().values():
			all_commits.remove(c)
	#hide commits that are in branches
	
	for c in sorted(all_commits,key=lambda x:x.commit_time):	
		print('{} {} {}'.format(time.ctime(c.commit_time),sha, c.message)) 
开发者ID:khilnani,项目名称:pythonista-scripts,代码行数:26,代码来源:find-orphans.py

示例4: _are_local_and_remote_heads_different

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def _are_local_and_remote_heads_different(self):
        local_head = Repo(self.cached_repo).head()
        remote_head = git.ls_remote(self.remote_url)[b"HEAD"]
        return local_head != remote_head 
开发者ID:src-d,项目名称:modelforge,代码行数:6,代码来源:index.py

示例5: parse_resource_url

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def parse_resource_url(self, resource_url):
        if not resource_url or not urlparse(resource_url.replace("@", "#")):
            raise InvalidIdentifierException("Please provide a valid URL.")

        matches = URL_RE.search(resource_url)
        if not matches:
            raise InvalidIdentifierException(
                "Please provide a valid "
                "([SCHEMA]://[HOST]/[PATH].git#[COMMIT_HASH]) Git Repo link.")
        self.repo_name = matches.group("name")
        self.repo_name = os.path.basename(self.repo_name)
        self.repo_url = matches.group("url")
        self.commit_hash = matches.group("commit")
        self.commit_link = resource_url 
开发者ID:google,项目名称:vulncode-db,代码行数:16,代码来源:gitrepo_handler.py

示例6: _fetch_or_init_repo

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def _fetch_or_init_repo(self):
        if self.repo:
            return True
        hostname = urlparse(self.repo_url).hostname
        if not hostname:
            return False
        repo_hostname = os.path.basename(hostname)
        repo_path = os.path.join(
            REPO_PATH,
            repo_hostname,
            # remove any leading slashes
            self.repo_name.replace("..", "__").lstrip("/"),
        )
        repo_path = os.path.normpath(repo_path)
        if not repo_path.startswith(REPO_PATH + repo_hostname):
            self._log_error("Invalid path: %s + %s => %s", self.repo_url,
                            self.repo_name, repo_path)
            raise Exception("Can't clone repo. Invalid repository.")

        if not os.path.isdir(repo_path):
            # Using GitPython here since Dulwich was throwing weird errors like:
            # "IOError: Not a gzipped file" when fetching resources like:
            # https://git.centos.org/r/rpms/dhcp.git
            if not GitPythonRepo.clone_from(
                    self.repo_url, repo_path, bare=True):
                self._log_error(f"Can't clone repo {self.repo_name}.")
                raise Exception("Can't clone repo.")

        self.repo = Repo(repo_path)
        return True 
开发者ID:google,项目名称:vulncode-db,代码行数:32,代码来源:gitrepo_handler.py

示例7: __post_init__

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [as 别名]
def __post_init__(self):
        path_string = str(self.repo_path.resolve())
        try:
            self.dulwich_repo = self.git.init(path_string)
        except FileExistsError:
            logger.info(f"Using existing repository at the following path: {self.repo_path}")
            self.dulwich_repo = Repo(path_string) 
开发者ID:Stvad,项目名称:CrowdAnki,代码行数:9,代码来源:dulwich_repo.py

示例8: create_github_release

# 需要导入模块: from dulwich import repo [as 别名]
# 或者: from dulwich.repo import Repo [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.repo.Repo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。