0
git --git-dir=/path/to/project/.git --work-tree=/path/to/project describe --abbrev=0 --tags

returns release-11.5.5

I have in my Python 3 code to get the latest release :

gd = '--git-dir=' + os.path.join(BASE_DIR, '.git');
wt = '--work-tree=' + BASE_DIR;
latest_release = subprocess.check_output(["git", gd, wt, "describe", "--abbrev=0", "--tags"]).strip()

returns b'release-11.5.5' From where did the enclosing b'' come from ?

anjanesh
  • 3,771
  • 7
  • 44
  • 58
  • It's a `bytes` literal: https://docs.python.org/3/library/stdtypes.html#bytes - the `b' '` isn't part of its contents. – CherryDT May 29 '21 at 11:11
  • 3
    Does this answer your question? [What does the 'b' character do in front of a string literal?](https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal) – Paul Lemarchand May 29 '21 at 11:19
  • `latest_git_version = str(latest_release).split('release-')[1]` - latest_git_version returns 11.5.5' - I assumed the trailing ' is coming from the b'' ? – anjanesh May 29 '21 at 11:21

0 Answers0