-
-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
g.extension: add branch option #1130
Conversation
Thanks for this quick improvement. I wonder if "main" shouldn't be automatically accepted since the term "master" is phased out in many git projects. Say, when I tell someone to install an addon from a recently created repo outside of the GRASS Addons then once doesn't easily realize that the default branch, at least in GitHub, is now called "main". (random link, article from Oct 2020): Perhaps "main" could be tried directly if "master" isn't there? |
As a sidenote, CI shows an error:
|
Thanks, now it works for both cases:
Could there be any other side-effects? |
I don`t think so, as download from both external repos and the official repo work, and local extensions are covert with unit tests. Your examples above, should probably go into the test suite (probably with r.example.plus from github/gitlab instead). In addition to adding an example with a branch to the documentation, it would probably good to extend the error message so that the users gets a hint which components of the module call to check (url, branch, or possibly proxy...)? |
However, the change will break download from older repos and probably user scripts: This fails now (but worked before): while this works (and failed before): We should probably point that out in the news following a next release? And that we make that change to follow the good reasons hosting services have for making that change... Furthermore, we would need to coordinate a possible renaming of the main branch with a point-release and change the now hardcoded branch name accordingly... |
That's why I wonder if a try-except solution could be used to try both (i.e., do not code any default answer), unless the user wants a third user defined name. |
Good idea. Had`nt thought of that. Will add a try-except for main/master. |
…t exist fix install add-on e.g.: g.extension r.example.plus url='https://github.com/wenzeslaus/r.example.plus'
…the main branch doesn't exist e.g. g.extension -j
Now all examples work! Remaining tiny issue is that this mentions "main.zip":
while it really uses "master.zip". Maybe worth a final tweak around this line? grass/scripts/g.extension/g.extension.py Line 1497 in 16d779a
|
This message is printed before download add-on. Will it first try to download it from the main branch, and if such a branch doesn't exist, it will try to download it from the master branch. We can move printing this message Fetching... inside Something like that:
Is it OK like this? |
The message would probably have to be moved to the install_extension_std_platforms function: grass/scripts/g.extension/g.extension.py Line 1488 in b5eefc2
and maybe changed to show the URL first after successfull / failed download. Or we add / move a URL check to that function or the download_source_code function ( grass/scripts/g.extension/g.extension.py Line 1442 in b5eefc2
Note also the verbose message there... |
In the last commits I tried to consolidate the messages. Please have another look.
|
Co-authored-by: Markus Neteler <neteler@gmail.com>
Co-authored-by: Markus Neteler <neteler@gmail.com>
I tried to backport following the HowToGit, but got the following error message:
Any idea? |
* add branch option * use main as default branch * try download add-on from the master branch if the main branch does not exist fix install add-on e.g.: g.extension r.example.plus url='https://github.com/wenzeslaus/r.example.plus' * try download add-ons files paths json file from the master branch if the main branch doesn't exist e.g. g.extension -j * add example with branch * consolidate messages * fix a flake8 issue * use format correctly * improve message Co-authored-by: Markus Neteler <neteler@gmail.com> * improve message Co-authored-by: Markus Neteler <neteler@gmail.com> Co-authored-by: Tomas Zigo <50632337+tmszi@users.noreply.github.com> Co-authored-by: Markus Neteler <neteler@gmail.com>
Yes, the backport of #683 was missing. Done now and this one also backported. |
Address #1128 and #625 by adding a 'branch' optionthat is only used when fetcing from online repos tht support branches...
Tests pass locally, and also e.g. this:
g.extension operation=add url=https://github.com/mundialis/t.rast.mosaic branch=main extension=t.rast.mosaic
works.
Please review.
Maybe I should add an example to the documentation? Anything else?
It is sort of a new feature, but maybe we can view lack of support for branches as a bug, after the move to git?