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


Python Tag.as_raw_string方法代码示例

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


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

示例1: test_serialize_simple

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import as_raw_string [as 别名]
    def test_serialize_simple(self):
        x = Tag()
        x.tagger = "Jelmer Vernooij <[email protected]>"
        x.name = "0.1"
        x.message = "Tag 0.1"
        x.object = (3, "d80c186a03f423a81b39df39dc87fd269736ca86")
        x.tag_time = 423423423
        x.tag_timezone = 0
        self.assertEquals("""object d80c186a03f423a81b39df39dc87fd269736ca86
type blob
tag 0.1
tagger Jelmer Vernooij <[email protected]> 423423423 +0000

Tag 0.1""", x.as_raw_string())
开发者ID:abderrahim,项目名称:dulwich,代码行数:16,代码来源:test_objects.py

示例2: tag_create

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import as_raw_string [as 别名]
def tag_create(
        repo, tag, author=None, message=None, annotated=False,
        objectish="HEAD", tag_time=None, tag_timezone=None,
        sign=False):
    """Creates a tag in git via dulwich calls:

    :param repo: Path to repository
    :param tag: tag string
    :param author: tag author (optional, if annotated is set)
    :param message: tag message (optional)
    :param annotated: whether to create an annotated tag
    :param objectish: object the tag should point at, defaults to HEAD
    :param tag_time: Optional time for annotated tag
    :param tag_timezone: Optional timezone for annotated tag
    :param sign: GPG Sign the tag
    """

    with open_repo_closing(repo) as r:
        object = parse_object(r, objectish)

        if annotated:
            # Create the tag object
            tag_obj = Tag()
            if author is None:
                # TODO(jelmer): Don't use repo private method.
                author = r._get_user_identity(r.get_config_stack())
            tag_obj.tagger = author
            tag_obj.message = message
            tag_obj.name = tag
            tag_obj.object = (type(object), object.id)
            if tag_time is None:
                tag_time = int(time.time())
            tag_obj.tag_time = tag_time
            if tag_timezone is None:
                # TODO(jelmer) Use current user timezone rather than UTC
                tag_timezone = 0
            elif isinstance(tag_timezone, str):
                tag_timezone = parse_timezone(tag_timezone)
            tag_obj.tag_timezone = tag_timezone
            if sign:
                import gpg
                with gpg.Context(armor=True) as c:
                    tag_obj.signature, unused_result = c.sign(
                        tag_obj.as_raw_string())
            r.object_store.add_object(tag_obj)
            tag_id = tag_obj.id
        else:
            tag_id = object.id

        r.refs[_make_tag_ref(tag)] = tag_id
开发者ID:jelmer,项目名称:dulwich,代码行数:52,代码来源:porcelain.py


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