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


Python Tag.name方法代码示例

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


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

示例1: create_tag_object

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
def create_tag_object(name, head):
	"""Create an annotated tag object from the given history.

	This rewrites a 'tag creation' history so that the head is a tag
	instead of a commit. This relies on the fact that in Subversion,
	tags are created using a 'svn cp' copy.

	Args:
	  name: Name of the tag.
	  head: Object ID of the head commit of a chain to be tagged.
	Returns:
	  The object ID of an annotated tag object, or the value of 'head'
	  if the tag could not be created.
	"""
	head_commit = gitrepo.get_object(head)

	# The tree of the commit should exactly match the tree of its parent.
	# If not, then is not a pure 'tagging' commit.
	if len(head_commit.parents) != 1:
		return head
	head_hat_commit = gitrepo.get_object(head_commit.parents[0])
	if head_commit.tree != head_hat_commit.tree:
		return head

	tag = Tag()
	tag.name = name
	tag.message = head_commit.message
	tag.tag_time = head_commit.commit_time
	tag.tag_timezone = head_commit.commit_timezone
	tag.object = (Commit, head_hat_commit.id)
	tag.tagger = head_commit.committer
	gitrepo.object_store.add_object(tag)

	return tag.id
开发者ID:bastianbin,项目名称:agito,代码行数:36,代码来源:agito.py

示例2: create_commit

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
def create_commit(data, marker='Default', blob=None):
    if not blob:
        blob = Blob.from_string('The blob content %s' % marker)
    tree = Tree()
    tree.add("thefile_%s" % marker, 0o100644, blob.id)
    cmt = Commit()
    if data:
        assert isinstance(data[-1], Commit)
        cmt.parents = [data[-1].id]
    cmt.tree = tree.id
    author = "John Doe %s <[email protected]>" % marker
    cmt.author = cmt.committer = author
    tz = parse_timezone('-0200')[0]
    cmt.commit_time = cmt.author_time = int(time())
    cmt.commit_timezone = cmt.author_timezone = tz
    cmt.encoding = "UTF-8"
    cmt.message = "The commit message %s" % marker
    tag = Tag()
    tag.tagger = "[email protected]"
    tag.message = "Annotated tag"
    tag.tag_timezone = parse_timezone('-0200')[0]
    tag.tag_time = cmt.author_time
    tag.object = (Commit, cmt.id)
    tag.name = "v_%s_0.1" % marker
    return blob, tree, tag, cmt
开发者ID:EvanKrall,项目名称:dulwich,代码行数:27,代码来源:test_swift.py

示例3: tag_handler

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
 def tag_handler(self, cmd):
     """Process a TagCommand."""
     tag = Tag()
     tag.tagger = cmd.tagger
     tag.message = cmd.message
     tag.name = cmd.tag
     self.repo.add_object(tag)
     self.repo.refs["refs/tags/" + tag.name] = tag.id
开发者ID:jelmer,项目名称:dulwich,代码行数:10,代码来源:fastexport.py

示例4: do_import

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
def do_import(commits, repo_loc, overwrite = True, author_="Règlement général <[email protected]>"):
    if exists(repo_loc):
        if overwrite:
            print("Deleting existing output directory: %s" % repo_loc)
            shutil.rmtree(repo_loc)

            os.mkdir(repo_loc)
            repo = Repo.init(repo_loc)
        else:
            repo = Repo(repo_loc)
    else:
        os.mkdir(repo_loc)
        repo = Repo.init(repo_loc)


    print("Importing %d commit(s)" % len(commits))

    for i, commit in enumerate(commits):
        date = commit[0]
        print("Commit %d dated %s, %d items" % (i, str(date), len(commit[1])))
        print("  authored by %s" % author_)
        paths_added, paths_removed = create_tree(commit, repo_loc, readme=False, main=commit[2] if len(commit) == 3 else {})
        repo.stage([path.encode(sys.getfilesystemencoding()) for path in set(paths_added)])

        index = repo.open_index()

        print("  Removing %d files" % len(paths_removed))
        for p in paths_removed:
            del index[p.encode(sys.getfilesystemencoding())]
        index.write()

        author = bytes(author_, "UTF-8")

        repo.do_commit(
            bytes("Version du %s" % date.strftime(FMT), "UTF-8"),
            committer=author,
            commit_timestamp=date.timestamp(),
            commit_timezone=int(TZ_PARIS.localize(date).strftime("%z")) * 36)

        ## create tag
        tag_name = bytes(date.strftime(ISO_8601), "UTF-8")
        object = parse_object(repo, "HEAD")
        tag = Tag()
        tag.tagger = author
        tag.name = tag_name
        tag.message = b''
        tag.object = (type(object), object.id)
        tag.tag_time = int(time.time())
        tag.tag_timezone = int(TZ_PARIS.localize(date).strftime("%z")) * 36
        repo.object_store.add_object(tag)
        tag_id = tag.id

        repo.refs[b'refs/tags/' + tag_name] = tag_id

    repo.close()
开发者ID:schambon,项目名称:rg-importer,代码行数:57,代码来源:import_rg.py

示例5: add_tag

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
 def add_tag(self, tag_name):
     commit = self._repo['refs/heads/master']
     tag = Tag()
     tag.name = tag_name
     tag.message = 'Tagged %s as %s' % (commit.id, tag_name)
     tag.tagger = self._author
     tag.object = (Commit, commit.id)
     tag.tag_time = int(time())
     tag.tag_timezone = self._time_zone
     self._update_store(tag)
     self.refs['refs/tags/%s' % tag_name] = tag.id
开发者ID:daqv,项目名称:portia-dashboard,代码行数:13,代码来源:repoman.py

示例6: test_serialize_simple

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

示例7: tag_create

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

示例8: _dulwich_tag

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
    def _dulwich_tag(self, tag, author, message=None):
        """ Creates a tag in git via dulwich calls:

                **tag** - string :: "<project>-[start|sync]-<timestamp>"
                **author** - string :: "Your Name <[email protected]>"
        """
        if not message:
            message = tag

        # Open the repo
        _repo = Repo(self.config['top_dir'])
        master_branch = 'master'

        # Build the commit object
        blob = Blob.from_string("empty")
        tree = Tree()
        tree.add(tag, 0100644, blob.id)

        commit = Commit()
        commit.tree = tree.id
        commit.author = commit.committer = author
        commit.commit_time = commit.author_time = int(time())
        tz = parse_timezone('-0200')[0]
        commit.commit_timezone = commit.author_timezone = tz
        commit.encoding = "UTF-8"
        commit.message = 'Tagging repo for deploy: ' + message

        # Add objects to the repo store instance
        object_store = _repo.object_store
        object_store.add_object(blob)
        object_store.add_object(tree)
        object_store.add_object(commit)
        _repo.refs['refs/heads/' + master_branch] = commit.id

        # Build the tag object and tag
        tag = Tag()
        tag.tagger = author
        tag.message = message
        tag.name = tag
        tag.object = (Commit, commit.id)
        tag.tag_time = commit.author_time
        tag.tag_timezone = tz
        object_store.add_object(tag)
        _repo['refs/tags/' + tag] = tag.id
开发者ID:rfaulkner,项目名称:Sartoris,代码行数:46,代码来源:sartoris.py

示例9: tag_create

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
def tag_create(
    repo, tag, author=None, message=None, annotated=False, objectish="HEAD", tag_time=None, tag_timezone=None
):
    """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
    """

    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()
            tag_obj.tagger = author
            tag_obj.message = message
            tag_obj.name = tag
            tag_obj.object = (type(object), object.id)
            tag_obj.tag_time = tag_time
            if tag_time is None:
                tag_time = int(time.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
            r.object_store.add_object(tag_obj)
            tag_id = tag_obj.id
        else:
            tag_id = object.id

        r.refs[b"refs/tags/" + tag] = tag_id
开发者ID:olasd,项目名称:dulwich,代码行数:45,代码来源:porcelain.py

示例10: tag

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
def tag(repo, tag, author, message):
    """Creates a tag in git via dulwich calls:

    :param repo: Path to repository
    :param tag: tag string
    :param author: tag author
    :param repo: tag message
    """

    r = open_repo(repo)

    # Create the tag object
    tag_obj = Tag()
    tag_obj.tagger = author
    tag_obj.message = message
    tag_obj.name = tag
    tag_obj.object = (Commit, r.refs['HEAD'])
    tag_obj.tag_time = int(time.time())
    tag_obj.tag_timezone = parse_timezone('-0200')[0]

    # Add tag to the object store
    r.object_store.add_object(tag_obj)
    r.refs['refs/tags/' + tag] = tag_obj.id
开发者ID:ChipJust,项目名称:dulwich,代码行数:25,代码来源:porcelain.py

示例11: _dulwich_tag

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
    def _dulwich_tag(self, tag, author, message=DEFAULT_TAG_MSG):
        """
        Creates a tag in git via dulwich calls:

        Parameters:
            tag - string :: "<project>-[start|sync]-<timestamp>"
            author - string :: "Your Name <[email protected]>"
        """

        # Open the repo
        _repo = Repo(self.config['top_dir'])

        # Create the tag object
        tag_obj = Tag()
        tag_obj.tagger = author
        tag_obj.message = message
        tag_obj.name = tag
        tag_obj.object = (Commit, _repo.refs['HEAD'])
        tag_obj.tag_time = int(time())
        tag_obj.tag_timezone = parse_timezone('-0200')[0]

        # Add tag to the object store
        _repo.object_store.add_object(tag_obj)
        _repo['refs/tags/' + tag] = tag_obj.id
开发者ID:davinirjr,项目名称:git-deploy,代码行数:26,代码来源:sartoris.py

示例12: parse_timezone

# 需要导入模块: from dulwich.objects import Tag [as 别名]
# 或者: from dulwich.objects.Tag import name [as 别名]
commit_id = repo.do_commit("first commit")
commit = repo.get_object(commit_id)
print commit


# get tree corresponding to the head commit
# tree_id = repo["HEAD"].tree
# print tree_id
object_store = repo.object_store

tags = repo.refs.subkeys("refs/tags")
print tags

tz = parse_timezone('-0200')[0]

tag_message = "Tag Annotation"
tag = Tag()
tag.tagger = author
tag.message = "message"
tag.name = "v0.1"
tag.object = (Commit, commit.id)
tag.tag_time = commit.author_time
tag.tag_timezone = tz
object_store.add_object(tag)
repo['refs/tags/HI'] = tag.id


tags = repo.refs.subkeys("refs/tags")
print tags
开发者ID:mfwarren,项目名称:FreeCoding,代码行数:31,代码来源:fc_2014_10_28.py


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