Skip to content

Commit

Permalink
Fall back on copying local directory instead of online github
Browse files Browse the repository at this point in the history
  • Loading branch information
j4b6ski committed Dec 9, 2024
1 parent e91a376 commit c8b9518
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
11 changes: 7 additions & 4 deletions tests/commands/init/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ def test_init_clones_default_template(capsys, request, temp_workdir):
args = ["init", "xyz"]

# try to avoid connecting to github when cloning example_package
git_dir = os.path.join(request.config.rootdir, '.git')
rootdir = str(request.config.rootdir)
git_dir = os.path.join(rootdir, '.git')
if os.path.exists(git_dir):
git_local_url = os.path.join('file://', request.config.rootdir)
git_local_url = os.path.join('file://', rootdir)
args.extend(["-t", git_local_url, "example_package"])
# currently this does fallback on github if the local repo is not available
# if needed we could take a dependency on gitpython and mock up a repo
else:
# copy from root directory instead of cloning
# if needed we could take a dependency on gitpython and mock up a repo
args.extend(["-t", rootdir, "example_package"])

args = parser.parse_args(args)
command = Command()
Expand Down
15 changes: 8 additions & 7 deletions tests/commands/init/test_unit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import tempfile
import pytest

from sinol_make.commands.init import Command

Expand All @@ -14,14 +15,14 @@ def copy_template(rootdir):

def test_clones_default_template(request):
# try to avoid connecting to github when cloning example_package
git_dir = os.path.join(request.config.rootdir, '.git')
if os.path.exists(git_dir):
git_local_url = os.path.join('file://', request.config.rootdir)
copy_template(git_local_url)
else:
# currently this does fallback on github if the local repo is not available
rootdir = str(request.config.rootdir)
git_dir = os.path.join(rootdir, '.git')
if not os.path.exists(git_dir):
# if needed we could take a dependency on gitpython and mock up a repo
copy_template(Command.DEFAULT_TEMPLATE)
pytest.skip(f".git not found in rootdir {rootdir}")

git_local_url = os.path.join('file://', rootdir)
copy_template(git_local_url)


def test_copies_local_template_absolute_path(request):
Expand Down

0 comments on commit c8b9518

Please sign in to comment.