reanahub / reana-client

REANA command-line client
http://reana-client.readthedocs.io/
MIT License
10 stars 45 forks source link

git-clone: improve first-time behaviour #534

Closed tiborsimko closed 2 years ago

tiborsimko commented 2 years ago

Current behaviour

The current developer instructions how to fork and clone all the REANA source code repositories, as presented in reana-dev --help | less, are not fully working. Here is a test case how to reproduce the issue:

$ mkvirtualenv reana -p python3.8
$ pip install git+git://github.com/reanahub/reana.git#egg=reana
$ mkdir -p /tmp/mysrc
$ cd /tmp/mysrc
$ reana-dev git-clone -c ALL -u tiborsimko
...
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'git rev-parse --show-toplevel' returned non-zero exit status 128.

The issue is a chicken-and-egg problem: the first repository cannot be cloned since reana-dev cannot detect where are REANA repositories located.

The first workaround is to clone the "reana" repository manually first:

$ git clone git@github.com:tiborsimko/reana

after which the cloning script works:

$ reana-dev git-clone -c ALL -u tiborsimko
[2021-07-07T09:29:17] : git clone git@github.com:tiborsimko/reana-auth-krb5
Cloning into 'reana-auth-krb5'...
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 46 (delta 15), reused 40 (delta 12), pack-reused 0
Receiving objects: 100% (46/46), 8.29 KiB | 8.29 MiB/s, done.
Resolving deltas: 100% (15/15), done.
...

However, this is not ideal, since this technique does not set "upstream" properly in the "reana" repository, for it sees it already existing and it won't touch it:

$ reana-dev git-clone -c reana -u tiborsimko
[2021-07-07T09:29:39] reana: Component seems already cloned. Skipping.

The second workaround is to edit reana/.git/config to manually add "upstream" sources.

Expected behaviour

We should allow users to override the behaviour of reana-dev git-clone so that it wouldn't look where the sources are but rather perform all the cloning for the first time automatically.

Since the cloning operation can be "dangerous" because it can clutter the working directory and because it may be rather time-consuming, we should proceed somewhat carefully:

Alternatively, we can introduce a new CLI option called say --target-directory that would allow to override the detection of source code repository locations, so that people would be able to write:

$ cd /tmp/mysrc
$ reana-dev git-clone -c ALL --target-directory .

and everything would be cloned without a glitch.

P.S.1: The documentation in reana-dev --help should be amended accordingly.

P.S.2: Later we could even switch to using gh CLI client, but that would be for another times.

tiborsimko commented 2 years ago

@marcdiazsan I have just realised that I had created this issue in a wrong repository... The fix will for for reana-dev which lives in the "reana" repository, please see reana/reana_dev/git.py file there...