37 lines
1.1 KiB
Diff
37 lines
1.1 KiB
Diff
--- poetry_core-1.7.0/src/poetry/core/vcs/__init__.py.orig 2023-08-20 16:51:29.236470000 +0200
|
|
+++ poetry_core-1.7.0/src/poetry/core/vcs/__init__.py 2023-08-26 11:17:23.989514400 +0200
|
|
@@ -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
|
|
|
|
@@ -25,16 +24,20 @@
|
|
vcs = None
|
|
else:
|
|
git_dir = subprocess.check_output(
|
|
- [executable(), "rev-parse", "--show-toplevel"],
|
|
+ [executable(), "rev-parse", "--show-prefix"],
|
|
stderr=subprocess.STDOUT,
|
|
text=True,
|
|
+ cwd=cwd
|
|
).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
|