From 8ed4ce7cc5cf3352a2f4c258fe98724bde152fbe Mon Sep 17 00:00:00 2001 From: DancingQuanta Date: Mon, 23 Aug 2021 19:34:08 +0100 Subject: [PATCH 1/3] A fix for tag prefix match on Windows --- src/git/from_vcs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/git/from_vcs.py b/src/git/from_vcs.py index e0c9af21..f11b538e 100644 --- a/src/git/from_vcs.py +++ b/src/git/from_vcs.py @@ -22,8 +22,10 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): version string, meaning we're inside a checked out source tree. """ GITS = ["git"] + TAG_PREFIX_REGEX = "*" if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] + TAG_PREFIX_REGEX = "\*" _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) @@ -36,7 +38,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): # if there isn't one, this yields HEX[-dirty] (no NUM) describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty", "--always", "--long", - "--match", "%s*" % tag_prefix], + "--match", + "%s%s" % (tag_prefix, TAG_PREFIX_REGEX)], cwd=root) # --long was added in git-1.5.5 if describe_out is None: From a4fbe3b844a32f64cd5d82ec43e567c14f6d9535 Mon Sep 17 00:00:00 2001 From: DancingQuanta Date: Tue, 31 Aug 2021 13:59:14 +0100 Subject: [PATCH 2/3] AAdded flakes8 ignore flag for \* --- src/git/from_vcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git/from_vcs.py b/src/git/from_vcs.py index f11b538e..e395946d 100644 --- a/src/git/from_vcs.py +++ b/src/git/from_vcs.py @@ -25,7 +25,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): TAG_PREFIX_REGEX = "*" if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] - TAG_PREFIX_REGEX = "\*" + TAG_PREFIX_REGEX = "\*" # noqa: W605 _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True) From 8c974175a722a4695c3044a239d53eaf6c3fe423 Mon Sep 17 00:00:00 2001 From: Andrew Tolmie Date: Tue, 31 Aug 2021 15:48:01 +0100 Subject: [PATCH 3/3] Use raw string for prefix regex Co-authored-by: Chris Markiewicz --- src/git/from_vcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git/from_vcs.py b/src/git/from_vcs.py index e395946d..5dce8dc9 100644 --- a/src/git/from_vcs.py +++ b/src/git/from_vcs.py @@ -25,7 +25,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): TAG_PREFIX_REGEX = "*" if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] - TAG_PREFIX_REGEX = "\*" # noqa: W605 + TAG_PREFIX_REGEX = r"\*" _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True)