35 lines
1.1 KiB
Diff
35 lines
1.1 KiB
Diff
--- poetry-core-1.0.7/poetry/core/vcs/__init__.py.orig 2022-02-17 06:29:13.585868700 +0100
|
|
+++ poetry-core-1.0.7/poetry/core/vcs/__init__.py 2022-02-17 06:29:14.200731000 +0100
|
|
@@ -8,23 +8,26 @@
|
|
|
|
|
|
def get_vcs(directory): # type: (Path) -> Git
|
|
- working_dir = Path.cwd()
|
|
- os.chdir(str(directory.resolve()))
|
|
+ cwd = str(directory.resolve())
|
|
|
|
try:
|
|
from .git import executable
|
|
|
|
git_dir = decode(
|
|
subprocess.check_output(
|
|
- [executable(), "rev-parse", "--show-toplevel"], stderr=subprocess.STDOUT
|
|
+ [executable(), "rev-parse", "--show-prefix"], stderr=subprocess.STDOUT,
|
|
+ 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
|