From e77d2d0ebb9487b696835f219e4a23a558462a55 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Apr 2011 12:14:04 +0200 Subject: Removed all parts of the reference implementation which doesn't require the git command. everything else was moved to GitDB. None of the tests is yet expected to run, although git-python should have less trouble getting the tests back up running than GitDB. plenty of code needs to be de-duplicated though in case of the tests, which will be some work --- git/refs/tag.py | 48 +++--------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index c09d814d..8ba9ba84 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -1,51 +1,11 @@ -from reference import Reference +from gitdb.ref.tag import TagReference as GitDB_TagReference +from git.util import RepoAliasMixin __all__ = ["TagReference", "Tag"] - - -class TagReference(Reference): - """Class representing a lightweight tag reference which either points to a commit - ,a tag object or any other object. In the latter case additional information, - like the signature or the tag-creator, is available. - - This tag object will always point to a commit object, but may carray additional - information in a tag object:: - - tagref = TagReference.list_items(repo)[0] - print tagref.commit.message - if tagref.tag is not None: - print tagref.tag.message""" - +class TagReference(GitDB_TagReference, GitDB_TagReference): __slots__ = tuple() - _common_path_default = "refs/tags" - @property - def commit(self): - """:return: Commit object the tag ref points to""" - obj = self.object - if obj.type == "commit": - return obj - elif obj.type == "tag": - # it is a tag object which carries the commit as an object - we can point to anything - return obj.object - else: - raise ValueError( "Tag %s points to a Blob or Tree - have never seen that before" % self ) - - @property - def tag(self): - """ - :return: Tag object this tag ref points to or None in case - we are a light weight tag""" - obj = self.object - if obj.type == "tag": - return obj - return None - - # make object read-only - # It should be reasonably hard to adjust an existing tag - object = property(Reference._get_object) - @classmethod def create(cls, repo, path, ref='HEAD', message=None, force=False, **kwargs): """Create a new tag reference. @@ -85,7 +45,5 @@ class TagReference(Reference): """Delete the given existing tag or tags""" repo.git.tag("-d", *tags) - - # provide an alias Tag = TagReference -- cgit v1.2.3 From 3fe1a7f87d511758adf2e56803cb3610b80c5f08 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 29 Apr 2011 17:04:37 +0200 Subject: Moved rev_parse code into gitdb, this probably broke pretty much here, which is still to be fixed of course --- git/refs/tag.py | 1 - 1 file changed, 1 deletion(-) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index 8ba9ba84..7bcff886 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -1,5 +1,4 @@ from gitdb.ref.tag import TagReference as GitDB_TagReference -from git.util import RepoAliasMixin __all__ = ["TagReference", "Tag"] -- cgit v1.2.3 From 9fc7b9a068189cc0d249d0870dfb0112ab5dec92 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 15:25:11 +0200 Subject: Made most primal imports work, but stopped here as there are many more changes when doing the merge --- git/refs/tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index 7bcff886..47c9ea4d 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -2,7 +2,7 @@ from gitdb.ref.tag import TagReference as GitDB_TagReference __all__ = ["TagReference", "Tag"] -class TagReference(GitDB_TagReference, GitDB_TagReference): +class TagReference(GitDB_TagReference): __slots__ = tuple() @classmethod -- cgit v1.2.3 From 4177eefd7bdaea96a529b00ba9cf751924ede202 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 19:43:22 +0200 Subject: Added all code from gitdb to gitpython. Next is to make it generally work. Then the tests will need some work --- git/refs/tag.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index 47c9ea4d..24a8e768 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -3,7 +3,45 @@ from gitdb.ref.tag import TagReference as GitDB_TagReference __all__ = ["TagReference", "Tag"] class TagReference(GitDB_TagReference): + """Class representing a lightweight tag reference which either points to a commit + ,a tag object or any other object. In the latter case additional information, + like the signature or the tag-creator, is available. + + This tag object will always point to a commit object, but may carray additional + information in a tag object:: + + tagref = TagReference.list_items(repo)[0] + print tagref.commit.message + if tagref.tag is not None: + print tagref.tag.message""" __slots__ = tuple() + _common_path_default = "refs/tags" + + @property + def commit(self): + """:return: Commit object the tag ref points to""" + obj = self.object + if obj.type == "commit": + return obj + elif obj.type == "tag": + # it is a tag object which carries the commit as an object - we can point to anything + return obj.object + else: + raise ValueError( "Tag %s points to a Blob or Tree - have never seen that before" % self ) + + @property + def tag(self): + """ + :return: Tag object this tag ref points to or None in case + we are a light weight tag""" + obj = self.object + if obj.type == "tag": + return obj + return None + + # make object read-only + # It should be reasonably hard to adjust an existing tag + object = property(Reference._get_object) @classmethod def create(cls, repo, path, ref='HEAD', message=None, force=False, **kwargs): -- cgit v1.2.3 From acf5e6ea64a2f24117f1d419c208ed1c38c43690 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 May 2011 15:03:14 +0200 Subject: replaced all gitdb strings with git --- git/refs/tag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index 24a8e768..7a0caa48 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -1,4 +1,4 @@ -from gitdb.ref.tag import TagReference as GitDB_TagReference +from git.ref.tag import TagReference as GitDB_TagReference __all__ = ["TagReference", "Tag"] -- cgit v1.2.3 From 7ae36c3e019a5cc16924d1b6007774bfb625036f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 May 2011 18:53:59 +0200 Subject: Started to fix imports - tests still have no chance to work as database changed drastically. Now the actual work begins --- git/refs/tag.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git/refs/tag.py') diff --git a/git/refs/tag.py b/git/refs/tag.py index 7a0caa48..3a1433be 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -1,8 +1,8 @@ -from git.ref.tag import TagReference as GitDB_TagReference +from reference import Reference __all__ = ["TagReference", "Tag"] -class TagReference(GitDB_TagReference): +class TagReference(Reference): """Class representing a lightweight tag reference which either points to a commit ,a tag object or any other object. In the latter case additional information, like the signature or the tag-creator, is available. -- cgit v1.2.3