Skip to content

Commit

Permalink
add support for dirty flag in git-based version number
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jul 28, 2018
1 parent 8fc21f4 commit 228a62d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions Urcheon/Repository.py
Expand Up @@ -622,29 +622,37 @@ def getVersion(self):

def computeVersion(self, reference):
commit = self.getCommit(reference)
version = ""
straight = False
version = "0"

# if self.tag_list == []:
# version = "0"

for tag in self.tag_list:
if self.isSame(tag, reference):
straight = True
# v9.0 → 9.0
return tag[1:]

if self.isAncestor(tag, reference):
version = tag[1:]
break

if self.tag_list == []:
version = "0"
elif self.isAncestor(tag, reference):
version = tag[1:]
break

if version == "":
version = "0"
if not straight:
time_stamp = self.getCompactHumanTimeStamp(reference)
short_id = self.getShortId(reference)
version += "+" + time_stamp + "+" + short_id

time_stamp = self.getCompactHumanTimeStamp(reference)
short_id = self.getShortId(reference)
version += "+" + time_stamp + "+" + short_id
if self.isDirty():
version += "+dirty"

return version

def isDirty(self):
proc = subprocess.call(self.git + ["diff", "--quiet"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
return not proc.numerator == 0

def getHexTimeStamp(self, reference):
# not used
commit_date = self.getDate(reference)
Expand Down

0 comments on commit 228a62d

Please sign in to comment.