mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 05:10:21 +03:00
Also use TemporaryDirectory
in git_checkout
This commit is contained in:
parent
1ac4144949
commit
ccbaaa3b3c
|
@ -1,3 +1,4 @@
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
from typing import Dict, Any, Union, List, Optional, Tuple, Iterable
|
from typing import Dict, Any, Union, List, Optional, Tuple, Iterable
|
||||||
from typing import TYPE_CHECKING, overload
|
from typing import TYPE_CHECKING, overload
|
||||||
import sys
|
import sys
|
||||||
|
@ -405,13 +406,14 @@ def git_checkout(
|
||||||
f"temporarily. To only download the files needed, make sure "
|
f"temporarily. To only download the files needed, make sure "
|
||||||
f"you're using Git v2.22 or above."
|
f"you're using Git v2.22 or above."
|
||||||
)
|
)
|
||||||
with make_tempdir() as tmp_dir:
|
with TemporaryDirectory() as tmp_dir:
|
||||||
cmd = f"git -C {tmp_dir} clone {repo} . -b {branch}"
|
tmp_path = Path(tmp_dir)
|
||||||
|
cmd = f"git -C {tmp_path} clone {repo} . -b {branch}"
|
||||||
run_command(cmd, capture=True)
|
run_command(cmd, capture=True)
|
||||||
# We need Path(name) to make sure we also support subdirectories
|
# We need Path(name) to make sure we also support subdirectories
|
||||||
try:
|
try:
|
||||||
source_path = tmp_dir / Path(subpath)
|
source_path = tmp_path / Path(subpath)
|
||||||
if not is_subpath_of(tmp_dir, source_path):
|
if not is_subpath_of(tmp_path, source_path):
|
||||||
err = f"'{subpath}' is a path outside of the cloned repository."
|
err = f"'{subpath}' is a path outside of the cloned repository."
|
||||||
msg.fail(err, repo, exits=1)
|
msg.fail(err, repo, exits=1)
|
||||||
if os.path.isdir(source_path):
|
if os.path.isdir(source_path):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user