
from __future__ import print_function
from subprocess import Popen, PIPE

dirty = Popen(["git", "diff-index", "--quiet", "HEAD"], stdout=PIPE).wait() != 0

commit_process = Popen(["git", "describe", "--tags", "--abbrev=0"], stdout=PIPE)
(version, err) = commit_process.communicate()

print("STABLE_GIT_VERSION %s%s" % (
    version.decode("utf-8").replace("\n", ""),
    "-dirty" if dirty else "")
)



from __future__ import print_function
from subprocess import Popen, PIPE

dirty = Popen(["git", "diff-index", "--quiet", "HEAD"], stdout=PIPE).wait() != 0

commit_process = Popen(["git", "describe", "--always", "--tags", "--abbrev=0"], stdout=PIPE)
(version, err) = commit_process.communicate()

print("STABLE_GIT_VERSION %s%s" % (
    version.decode("utf-8").replace("\n", ""),
    "-dirty" if dirty else "")
)


Make git describe --always return a value
Make git describe --always return a value

This means that the latest commit will be stamped if there are no tags.
  
  from __future__ import print_function
  from subprocess import Popen, PIPE
  
  dirty = Popen(["git", "diff-index", "--quiet", "HEAD"], stdout=PIPE).wait() != 0
  
- commit_process = Popen(["git", "describe", "--tags", "--abbrev=0"], stdout=PIPE)
+ commit_process = Popen(["git", "describe", "--always", "--tags", "--abbrev=0"], stdout=PIPE)
  (version, err) = commit_process.communicate()
  
  print("STABLE_GIT_VERSION %s%s" % (
      version.decode("utf-8").replace("\n", ""),
      "-dirty" if dirty else "")
  )
  
  
Make git describe --always return a value
## Code Before:

from __future__ import print_function
from subprocess import Popen, PIPE

dirty = Popen(["git", "diff-index", "--quiet", "HEAD"], stdout=PIPE).wait() != 0

commit_process = Popen(["git", "describe", "--tags", "--abbrev=0"], stdout=PIPE)
(version, err) = commit_process.communicate()

print("STABLE_GIT_VERSION %s%s" % (
    version.decode("utf-8").replace("\n", ""),
    "-dirty" if dirty else "")
)


## Instruction:
Make git describe --always return a value
## Code After:

from __future__ import print_function
from subprocess import Popen, PIPE

dirty = Popen(["git", "diff-index", "--quiet", "HEAD"], stdout=PIPE).wait() != 0

commit_process = Popen(["git", "describe", "--always", "--tags", "--abbrev=0"], stdout=PIPE)
(version, err) = commit_process.communicate()

print("STABLE_GIT_VERSION %s%s" % (
    version.decode("utf-8").replace("\n", ""),
    "-dirty" if dirty else "")
)

