From 803ae9037ab2be395812e844e3413259f1b5cb86 Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Mon, 22 Nov 2021 10:28:12 +0100 Subject: [PATCH 1/3] Add opts support to git_clone func --- reframe/utility/osext.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index 6c1894b1f1..cc1b154589 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -415,10 +415,11 @@ def is_url(s): return parsed.scheme != '' and parsed.netloc != '' -def git_clone(url, targetdir=None, timeout=5): +def git_clone(url, targetdir=None, opts=[], timeout=5): '''Clone a git repository from a URL. :arg url: The URL to clone from. + :arg opts: List of options to be passed to `git clone` command :arg timeout: Timeout in seconds when checking if the url is a valid repository. :arg targetdir: The directory where the repository will be cloned to. If @@ -429,7 +430,8 @@ def git_clone(url, targetdir=None, timeout=5): raise ReframeError('git repository does not exist') targetdir = targetdir or '' - run_command(f'git clone {url} {targetdir}', check=True) + opts = ' '.join(opts) + run_command(f'git clone {opts} {url} {targetdir}', check=True) def git_repo_exists(url, timeout=5): From 961fb35e37565cd7dc40c26d2f6d79e51d0782ab Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri <44365948+mahendrapaipuri@users.noreply.github.com> Date: Mon, 22 Nov 2021 11:48:21 +0100 Subject: [PATCH 2/3] Use `opts=None` instead of `[]` --- reframe/utility/osext.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index cc1b154589..45d8b6f118 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -415,7 +415,7 @@ def is_url(s): return parsed.scheme != '' and parsed.netloc != '' -def git_clone(url, targetdir=None, opts=[], timeout=5): +def git_clone(url, targetdir=None, opts=None, timeout=5): '''Clone a git repository from a URL. :arg url: The URL to clone from. @@ -430,7 +430,7 @@ def git_clone(url, targetdir=None, opts=[], timeout=5): raise ReframeError('git repository does not exist') targetdir = targetdir or '' - opts = ' '.join(opts) + opts = ' '.join(opts) if opts is not None else '' run_command(f'git clone {opts} {url} {targetdir}', check=True) From 01e6da4f79f0003b10fd4c9a6482ff26c84281c3 Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri <44365948+mahendrapaipuri@users.noreply.github.com> Date: Mon, 22 Nov 2021 12:10:13 +0100 Subject: [PATCH 3/3] Update `git_clone` docstring Co-authored-by: Theofilos Manitaras --- reframe/utility/osext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reframe/utility/osext.py b/reframe/utility/osext.py index 45d8b6f118..1b231c3567 100644 --- a/reframe/utility/osext.py +++ b/reframe/utility/osext.py @@ -419,7 +419,7 @@ def git_clone(url, targetdir=None, opts=None, timeout=5): '''Clone a git repository from a URL. :arg url: The URL to clone from. - :arg opts: List of options to be passed to `git clone` command + :arg opts: List of options to be passed to the `git clone` command :arg timeout: Timeout in seconds when checking if the url is a valid repository. :arg targetdir: The directory where the repository will be cloned to. If