Skip to content
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: get branch from version #1700

Merged
merged 21 commits into from
Jul 21, 2021
Merged
26 changes: 12 additions & 14 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,9 @@ def install_extension_std_platforms(name, source, url, branch):
"""Install extension on standard platforms"""
gisbase = os.getenv("GISBASE")
# TODO: workaround, https://github.com/OSGeo/grass-addons/issues/528
source_url = "https://github.com/OSGeo/grass-addons/tree/master/grass7/"
source_url = "https://github.com/OSGeo/grass-addons/tree/grass{}/src".format(
version[0]
)

# to hide non-error messages from subprocesses
if grass.verbosity() <= 2:
Expand Down Expand Up @@ -2303,8 +2305,8 @@ def resolve_source_code(url=None, name=None, branch=None, fork=False):
module_class = get_module_class_name(name)
# note: 'trunk' is required to make URL usable for 'svn export' call
git_url = (
"https://github.com/OSGeo/grass-addons/trunk/"
"grass{version}/{module_class}/{module_name}".format(
"https://github.com/OSGeo/grass-addons/branches/"
"grass{version}/src/{module_class}/{module_name}".format(
version=version[0], module_class=module_class, module_name=name
)
)
Expand All @@ -2319,20 +2321,16 @@ def resolve_source_code(url=None, name=None, branch=None, fork=False):
module_class = get_module_class_name(name)

# note: 'trunk' is required to make URL usable for 'svn export' call
if branch in ["master", "main"]:
svn_reference = "trunk"
if branch is None or branch in ["master", "main"]:
svn_reference = "branches/grass{}".format(version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing. None (default) may be expected to resolve to the default branch which is represented by trunk in Subversion interface, although perhaps default resulting in the version branch makes sense in this context. However, explicit master or main should resolve to branch/master and branch/main unless there is a clear reason to do it otherwise.

I though -o is somewhat "behave as with the official repository" which is broader than its defintion "url refers to a fork of the official extension repository". Also depends on what people think fork is. Overall, this might be limiting when you let's say create an institutional repo which should work as the official repository, but you support only one version.

else:
svn_reference = "branches/{}".format(branch)

git_url = (
"{url}/{branch}/"
"grass{version}/{module_class}/{module_name}".format(
url=url,
version=version[0],
module_class=module_class,
module_name=name,
branch=svn_reference,
)
git_url = "{url}/{branch}/" "src/{module_class}/{module_name}".format(
ninsbl marked this conversation as resolved.
Show resolved Hide resolved
url=url,
module_class=module_class,
module_name=name,
branch=svn_reference,
)
# trac_url = 'https://trac.osgeo.org/grass/browser/grass-addons/' \
# 'grass{version}/{module_class}/{module_name}?format=zip' \
Expand Down