Use 'git describe' to get current version number in checkVersions()
authorRalf Jung <post@ralfj.de>
Wed, 13 Feb 2013 16:15:40 +0000 (17:15 +0100)
committerRalf Jung <post@ralfj.de>
Wed, 13 Feb 2013 16:15:40 +0000 (17:15 +0100)
The old method could not deal well with multiple tags for the same commit

vcs.py

diff --git a/vcs.py b/vcs.py
index d6e2028bd5be2bb48f9b35760ae6fefb0b36240e..73ffb10113c2c005aac7f9668b8fd01d2e4131ee 100644 (file)
--- a/vcs.py
+++ b/vcs.py
@@ -86,24 +86,18 @@ class Git:
        def version(self):
                repo = git.Repo(self.folder)
                v = repo.git.describe()
        def version(self):
                repo = git.Repo(self.folder)
                v = repo.git.describe()
-               return v[len(get_non_digit_prefix(v)):] # remove the letter prefix from v (so that it starts with a number)
+               return v[len(get_non_digit_prefix(v)):] # remove the non-digit prefix from v (so that it starts with a number)
 
        def checkVersions(self):
 
        def checkVersions(self):
-               self.update(mode =  MODE_FETCH)
+               self.update(mode = MODE_FETCH)
                repo = git.Repo(self.folder)
                repo = git.Repo(self.folder)
-               # get tag name for current commit, if any
-               commit = repo.commit(self.commit)
-               commitTag = filter(lambda t: t.commit == commit, repo.tags)
-               if not commitTag:
-                       print "Version is not a tag"
-                       return
-               currentVersion = str(commitTag[0])
-               # get sorted list of tag names with the same letter prefix and higher version number
+               currentVersion = repo.git.describe()
+               # get sorted list of tag names with the same non-digit prefix and higher version number
                tags = map(str, repo.tags)
                tags = filter(lambda t: get_non_digit_prefix(t) == get_non_digit_prefix(currentVersion) and natural_sort_key(t) > natural_sort_key(currentVersion), tags)
                if not tags: return
                tags.sort(key = natural_sort_key)
                tags = map(str, repo.tags)
                tags = filter(lambda t: get_non_digit_prefix(t) == get_non_digit_prefix(currentVersion) and natural_sort_key(t) > natural_sort_key(currentVersion), tags)
                if not tags: return
                tags.sort(key = natural_sort_key)
-               print "Versions newer than "+self.commit+" available:"
+               print "Versions newer than "+currentVersion+" available:"
                print tags
 
 # Fetch updates via SVN
                print tags
 
 # Fetch updates via SVN