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


Python objects.Tag类代码示例

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


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

示例1: tag_handler

 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,代码行数:8,代码来源:fastexport.py

示例2: test_parse_no_message

 def test_parse_no_message(self):
     x = Tag()
     x.set_raw_string(self.make_tag_text(message=None))
     self.assertEqual(None, x.message)
     self.assertEqual(
         b'Linus Torvalds <[email protected]>', x.tagger)
     self.assertEqual(datetime.datetime.utcfromtimestamp(x.tag_time),
                      datetime.datetime(2007, 7, 1, 19, 54, 34))
     self.assertEqual(-25200, x.tag_timezone)
     self.assertEqual(b'v2.6.22-rc7', x.name)
开发者ID:atbradley,项目名称:dulwich,代码行数:10,代码来源:test_objects.py

示例3: test_parse

 def test_parse(self):
     x = Tag()
     x.set_raw_string(self.make_tag_text())
     self.assertEqual("Linus Torvalds <[email protected]>", x.tagger)
     self.assertEqual("v2.6.22-rc7", x.name)
     object_type, object_sha = x.object
     self.assertEqual("a38d6181ff27824c79fc7df825164a212eff6a3f", object_sha)
     self.assertEqual(Commit, object_type)
     self.assertEqual(datetime.datetime.utcfromtimestamp(x.tag_time), datetime.datetime(2007, 7, 1, 19, 54, 34))
     self.assertEqual(-25200, x.tag_timezone)
开发者ID:emperorcezar,项目名称:dulwich,代码行数:10,代码来源:test_objects.py

示例4: test_parse_no_tagger

    def test_parse_no_tagger(self):
        x = Tag()
        x.set_raw_string("""object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7

Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
""")
        self.assertEquals(None, x.tagger)
        self.assertEquals("v2.6.22-rc7", x.name)
开发者ID:abderrahim,项目名称:dulwich,代码行数:17,代码来源:test_objects.py

示例5: create_tag_object

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,代码行数:34,代码来源:agito.py

示例6: tag_create

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,代码行数:50,代码来源:porcelain.py

示例7: create_commit

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,代码行数:25,代码来源:test_swift.py

示例8: test_parse_ctime

    def test_parse_ctime(self):
        x = Tag()
        x.set_raw_string("""object a38d6181ff27824c79fc7df825164a212eff6a3f
type commit
tag v2.6.22-rc7
tagger Linus Torvalds <[email protected]> Sun Jul 1 12:54:34 2007 -0700

Linux 2.6.22-rc7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGiAaAF3YsRnbiHLsRAitMAKCiLboJkQECM/jpYsY3WPfvUgLXkACgg3ql
OK2XeQOiEeXtT76rV4t2WR4=
=ivrA
-----END PGP SIGNATURE-----
""")
        self.assertEquals("Linus Torvalds <[email protected]>", x.tagger)
        self.assertEquals("v2.6.22-rc7", x.name)
开发者ID:abderrahim,项目名称:dulwich,代码行数:18,代码来源:test_objects.py

示例9: test_check_tag_with_overflow_time

    def test_check_tag_with_overflow_time(self):
        """Date with overflow should raise an ObjectFormatException when checked

        """
        author = 'Some Dude <[email protected]> %s +0000' % (MAX_TIME+1, )
        tag = Tag.from_string(self.make_tag_text(
            tagger=(author.encode())))
        with self.assertRaises(ObjectFormatException):
            tag.check()
开发者ID:atbradley,项目名称:dulwich,代码行数:9,代码来源:test_objects.py

示例10: test_serialize_simple

    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,代码行数:14,代码来源:test_objects.py

示例11: do_import

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,代码行数:55,代码来源:import_rg.py

示例12: add_tag

 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,代码行数:11,代码来源:repoman.py

示例13: _dulwich_tag

    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,代码行数:44,代码来源:sartoris.py

示例14: tag_create

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,代码行数:43,代码来源:porcelain.py

示例15: tag

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,代码行数:23,代码来源:porcelain.py


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