-
-
Notifications
You must be signed in to change notification settings - Fork 314
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: use git sparse-checkout instead of SVN #2895
Conversation
I’m glad you could make this effort to rework the add-on install! I have not tested nor reviewed the code, but in my opinion, in principle this update should be seriously considered for 8.3. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a shallow review. General code layout looks good. The Git code promising.
The gscript/grass -> gs is needed, but it makes this PR harder to navigate. It is okay to use it for the new code, i.e., have both import grass.script as gs
and import grass.script as gscript
.
scripts/g.extension/g.extension.py
Outdated
return directory | ||
|
||
|
||
def download_source_code_official_github(url, name, outdev, directory=None): | ||
def download_source_code_official_github( | ||
url, name, branch, major_grass_version=8, directory=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid major_grass_version=8
this would be difficult to maintain.
scripts/g.extension/g.extension.py
Outdated
) | ||
% file_url | ||
"Unable to parse '{url}'. Trying to scan" | ||
" git repository (may take some time)..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is actually a "Git repository" like before it was "Subversion repository".
scripts/g.extension/g.extension.py
Outdated
url="https://github.com/osgeo/grass-addons", | ||
working_directory=None, | ||
official_repository_structure=True, | ||
major_grass_version=8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another place which has the hardcoded major version. See all the desperate commits trying to fix version numbers around every release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Yes, that was planned to be set to version extracted at the bottom of the module, forgot to plug that in...
scripts/g.extension/g.extension.py
Outdated
repo_directory = ( | ||
self.url.split("/")[-1][0:-4] | ||
if self.url.endswith(".git") | ||
else self.url.split("/")[-1] | ||
) | ||
self.local_copy = self.working_directory / repo_directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the repo_directory
only purpose is to find the directory, you can do it ahead of time. Find the name in the URL, than use the name with git command, then you have it fully under control, can check if it already exists (but the git call can still fail if two g.extensions run in parallel).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This is unnecessary complicated. Using a fixed directory name now. Maybe this needs reconsidering when git clone should be used for all git compatible sources...
scripts/g.extension/g.extension.py
Outdated
self.url.split("/")[-1][0:-4] | ||
if self.url.endswith(".git") | ||
else self.url.split("/")[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about best practice for splitting URLs (split vs Path vs urlparse), but rsplit with max splits will be better than split.
scripts/g.extension/g.extension.py
Outdated
) | ||
branch_list = gs.decode(branch_list.communicate()[0]) | ||
return { | ||
branch.split("/")[-1]: branch.split("\t")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rsplit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented
Should address also: #2186 Maybe a thorough cleanup and refactoring of |
I did test this and installed some addons, seems to work fine. Is there any particular weak spot, that needs testing? As I mentioned in #2717 (comment) you may try to remove the |
Are there any concerns about the version of git? We need to specify minimum version, no? |
In what git version sparse checkout started working like the extension uses? It wasn't possible before, hence why SVN was kept |
Probably Git 2.27 should be needed (https://stackoverflow.com/a/62480045), sparse-checkout introduced in 2.25 (https://github.com/git/git/blob/e25cabbf6b34e4a6e903d65102d87055cc994778/Documentation/RelNotes/2.25.0.txt#L67) |
Good points! So, Debian 10 could be problematic and CentOS < 8 will not work either, same for Ubunut 18.04. What distros and older versions do we want to support with recent code? MS Windows is not affected as there svn is not available either and ionly precompiled addons are used... |
I don't have a direct answer, but whatever we want to support 100% should be in the CI (if it is not there, it should be added). The limitations: We are using pre-configured VMs, so the CI environments are not completely same as default installations. We don't test every Linux distro, we just assume that what we test is a good proxy. The recent Ubuntu update in CI was not motivated by version coverage (#2730). CentOS looks like old-system test, but it actually never achieved that; it's a conda on old system test. We don't run tests on CentOS. We are also still maintaining 7.8 right now if one needs a legacy version. |
Given that GitHub stops SVN support January 8th 2024 (in less than a year) then there is no point in keeping the current svn code. This means also 7.8 g.extension stops working next year. A fallback solution could be to clone the entire repository, no? I think at the very least this PR should check for the version (2.25 minimum I guess) and suggest to update git version instead of failing. |
Thanks for the feedbak! It seems first versions of sparse checkout were introduced in git versions as early as 1.7: |
Strange, considering https://github.blog/2020-01-13-highlights-from-git-2-25/ |
From source above:
|
OK, added a fall-back solution now, that uses a normal checkout for git versions < 2.25. |
Here is a comparison of
and
By using A question is if it would be appropriate to get this into 8.3 or if it should be tested a bit more first... |
Personally I'd welcome it for 8.3. Note, it is RC to come, great opportunity for broader testing!
👍 Just a note on the in-line comments on the |
I tested little bit, I am for 8.3 as well. |
Thanks for the feedback @nilason and @petrasovaa |
Took the liberty to merge this as no RC is out yet and there were no objections to including it into 8.3. |
* unified imports * use git sparse checkout * version dependent fall-back * test on mac
This PR replaces svn export to fetch single addons from the official addon repository with git sparse-checkout. Thus, the dependency on SVN becomes only optional (if SVN repositories are used). See #2834
It also reduces the likelihood that the GitHub API is used (and rate limit is hit) as info about latest changes can be taken from the git logs.
Could be a first step towards also supporting installation of multiple AddOns (or all). Because of possible extented use of the introduced functionality it is implemented as a GitAdapter class.
More cleanup in existing g.extension code should be done (but that is a different PR)...
Leaving the milestone open as I do not know if it is feasible (or appropriate) to get this into 8.3...