From 31f42cf3ae7c5ce230de57f227b90c1e85e2d847 Mon Sep 17 00:00:00 2001 From: Derek Harland Date: Tue, 14 Jul 2020 11:05:51 +1200 Subject: [PATCH] Alter rev-parse syntax to support msys git On windows, msys and cygwin versions of git need braces to be escaped when they are invoked via subprocess. (This appears to be is a side effect of the machinery that converts windows paths to posix-like paths for the executable). If they are not escaped, then "rev^{commit]" becomes a meaningless "rev^commit" to an msys git, resulting in an error. In contrast, we do not want to escape the braces if passing "rev^{commit}" to any other form of git. We can avoid having to decide whether escaping is needed by using the alternative notation "^0". --- poetry/vcs/git.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/poetry/vcs/git.py b/poetry/vcs/git.py index 8992c410b76..bca4d325065 100644 --- a/poetry/vcs/git.py +++ b/poetry/vcs/git.py @@ -229,9 +229,15 @@ def rev_parse(self, rev, folder=None): # type: (...) -> str folder.as_posix(), ] - # We need "^{commit}" to ensure that the commit SHA of the commit the - # tag points to is returned, even in the case of annotated tags. - args += ["rev-parse", rev + "^{commit}"] + # We need "^0" (an alternative to "^{commit}") to ensure that the + # commit SHA of the commit the tag points to is returned, even in + # the case of annotated tags. + # + # We deliberately avoid the "^{commit}" syntax itself as on some + # platforms (cygwin/msys to be specific), the braces are interpreted + # as special characters and would require escaping, while on others + # they should not be escaped. + args += ["rev-parse", rev + "^0"] return self.run(*args)