Skip to content

Commit 58bf319

Browse files
committed
Merges #32
2 parents 5e7ccc7 + 41f207a commit 58bf319

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

graal/graal.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,14 @@ class GraalCommand(GitCommand):
459459
def _pre_init(self):
460460
"""Initialize repositories directory path"""
461461

462-
git_path = self.parsed_args.git_path
463-
setattr(self.parsed_args, 'gitpath', git_path)
462+
if not self.parsed_args.git_path:
463+
base_path = os.path.expanduser('~/.graal/repositories/')
464+
processed_uri = self.parsed_args.uri.lstrip('/')
465+
git_path = os.path.join(base_path, processed_uri) + '-git'
466+
else:
467+
git_path = self.parsed_args.git_path
468+
469+
setattr(self.parsed_args, 'git_path', git_path)
464470

465471
@staticmethod
466472
def setup_cmd_parser(categories, exec_path=False):

tests/test_graal.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,17 @@ def test_backend_class(self):
616616

617617
self.assertIs(GraalCommand.BACKEND, Graal)
618618

619-
def test_gitpath_init(self):
619+
@unittest.mock.patch('os.path.expanduser')
620+
def test_gitpath_init(self, mock_expanduser):
620621
"""Test gitpath initialization"""
621622

623+
mock_expanduser.return_value = os.path.join(self.tmp_path, 'testpath')
624+
args = ['http://example.com/']
625+
626+
cmd = MockedGraalCommand(*args)
627+
self.assertEqual(cmd.parsed_args.git_path,
628+
os.path.join(self.tmp_path, 'testpath/http://example.com/' + '-git'))
629+
622630
args = ['http://example.com/',
623631
'--git-path', '/tmp/gitpath']
624632

0 commit comments

Comments
 (0)