Skip to content

Commit

Permalink
Merge pull request mih#28 from datalad/bf-version
Browse files Browse the repository at this point in the history
Make version detection robust to GIT_DIR specification
  • Loading branch information
mih authored Jan 11, 2022
2 parents f6ef763 + a3b022c commit ec54055
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions datalad_helloworld/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]

out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
out, rc = run_command(GITS, ["--git-dir=.git", "rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
if rc != 0:
if verbose:
Expand All @@ -234,15 +234,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):

# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
describe_out, rc = run_command(GITS, ["--git-dir=.git", "describe", "--tags", "--dirty",
"--always", "--long",
"--match", "%s*" % tag_prefix],
cwd=root)
# --long was added in git-1.5.5
if describe_out is None:
raise NotThisMethod("'git describe' failed")
describe_out = describe_out.strip()
full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
full_out, rc = run_command(GITS, ["--git-dir=.git", "rev-parse", "HEAD"], cwd=root)
if full_out is None:
raise NotThisMethod("'git rev-parse' failed")
full_out = full_out.strip()
Expand Down Expand Up @@ -293,12 +293,12 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
else:
# HEX: no tags
pieces["closest-tag"] = None
count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"],
count_out, rc = run_command(GITS, ["--git-dir=.git", "rev-list", "HEAD", "--count"],
cwd=root)
pieces["distance"] = int(count_out) # total number of commits

# commit date: see ISO-8601 comment in git_versions_from_keywords()
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
date = run_command(GITS, ["--git-dir=.git", "show", "-s", "--format=%ci", "HEAD"],
cwd=root)[0].strip()
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)

Expand Down

0 comments on commit ec54055

Please sign in to comment.