Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions graal/graal.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,14 @@ class GraalCommand(GitCommand):
def _pre_init(self):
"""Initialize repositories directory path"""

git_path = self.parsed_args.git_path
setattr(self.parsed_args, 'gitpath', git_path)
if not self.parsed_args.git_path:
base_path = os.path.expanduser('~/.graal/repositories/')
processed_uri = self.parsed_args.uri.lstrip('/')
git_path = os.path.join(base_path, processed_uri) + '-git'
else:
git_path = self.parsed_args.git_path

setattr(self.parsed_args, 'git_path', git_path)

@staticmethod
def setup_cmd_parser(categories, exec_path=False):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_graal.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,17 @@ def test_backend_class(self):

self.assertIs(GraalCommand.BACKEND, Graal)

def test_gitpath_init(self):
@unittest.mock.patch('os.path.expanduser')
def test_gitpath_init(self, mock_expanduser):
"""Test gitpath initialization"""

mock_expanduser.return_value = os.path.join(self.tmp_path, 'testpath')
args = ['http://example.com/']

cmd = MockedGraalCommand(*args)
self.assertEqual(cmd.parsed_args.git_path,
os.path.join(self.tmp_path, 'testpath/http://example.com/' + '-git'))

args = ['http://example.com/',
'--git-path', '/tmp/gitpath']

Expand Down