Files
MINGW-packages/mingw-w64-python-poetry-core/0002-msys-git-support.patch
مهدي شينون (Mehdi Chinoune) bc687d6bc7 python-poetry-core: update to 1.2.0
2022-09-20 19:46:04 +01:00

38 lines
1002 B
Diff

--- a/src/poetry/core/vcs/__init__.py
+++ b/src/poetry/core/vcs/__init__.py
@@ -9,8 +9,7 @@
def get_vcs(directory: Path) -> Git | None:
- working_dir = Path.cwd()
- os.chdir(str(directory.resolve()))
+ cwd = str(directory.resolve())
vcs: Git | None
@@ -19,17 +18,21 @@
git_dir = (
subprocess.check_output(
- [executable(), "rev-parse", "--show-toplevel"], stderr=subprocess.STDOUT
+ [executable(), "rev-parse", "--show-prefix"], stderr=subprocess.STDOUT,
+ cwd=cwd
)
.decode()
.strip()
)
+ git_dir = git_dir.strip()[:-1] # remove the trailing os.sep
+ if not git_dir:
+ git_dir = cwd
+ else:
+ git_dir = cwd[:-len(git_dir)]
vcs = Git(Path(git_dir))
except (subprocess.CalledProcessError, OSError, RuntimeError):
vcs = None
- finally:
- os.chdir(str(working_dir))
return vcs