Skip to content

Commit 430a98e

Browse files
authored
add(option): 'repository_plugin_url' to set the custom plugin repository (plugins.xml) base URL (#413)
<!-- Thanks for your contribution to this project! Please make sure you read the following guidelines before opening a pull request. --> ## Description It allows the user to set it once for all in the config file instead of specifying it for every package command run. It still can be overriden by the -u/--plugin-repo-url CLI option. Funded by oslandia <!-- osl:grant-oss-2026 --> ## Author's checklist - [x] I have read the [contributing guidelines](https://github.com/opengisch/qgis-plugin-ci?tab=contributing-ov-file#readme) and my pull request follows them. - [x] my commits tend to comply with [Conventional Commits](https://www.conventionalcommits.org/); so they are descriptive and explain the rationale for changes. Messages and description are self-explanatory to make the git log a readable story of the project. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] I have added necessary documentation (if appropriate). - [ ] commits which fix bugs include `Fixes #11111` at the bottom of the commit message. > [!TIP] > If you forgot to do this, don't be shy and write the same statement into this text field with the pull request description. ### AI tool usage - [ ] AI tool(s) (Copilot, Claude, or something similar) supported my development of this PR. See our [policy about AI tool use](https://github.com/qgis/QGIS-Enhancement-Proposals/blob/master/qep-408-ai-tool-policy.md). Use of AI tools *must* be indicated. Failure to be honest might result in banning. <!-- **BEFORE HITTING SUBMIT** -- Please TEST your changes thoroughly. This is YOUR responsibility! Do NOT rely on the project maintainers to do this for you! Thanks you! IMPORTANT NOTES FOR FIRST TIME CONTRIBUTORS =========================================== Congratulations, you are about to make a pull request to QGIS or one of its related project! To make this as easy and pleasurable for everyone, please take the time to read these lines before opening the pull request. Include a few sentences describing the overall goals for this pull request (PR). If applicable also add screenshots or - even better - screencasts. Include both: *what* you changed and *why* you changed it. If this is a pull request that adds new functionality which needs documentation, give an especially detailed explanation. In this case, start with a short abstract and then write some text that can be copied 1:1 to the documentation in the best case. --> ## Reviewer's checklist - [ ] I remember to check the "Author's checklist" above and ask the author to update the PR description if any of the items are not checked. - [ ] I remember that welcoming new contributors is more important than nitpicking on code style. I will be kind and respectful in my review comments.
2 parents 2ed7e61 + 7d90de7 commit 430a98e

7 files changed

Lines changed: 59 additions & 3 deletions

File tree

.qgis-plugin-ci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ github_organization_slug: opengisch
33
plugin_path: qgis_plugin_CI_testing
44
project_slug: qgis-plugin-ci
55
repository_plugin_id: "demo.qgis-plugins.ci:99999"
6+
repository_plugin_url: https://opengisch.github.io/qgis-plugin-ci/
67
repository_url_raw: https://raw.githubusercontent.com/opengisch/qgis-plugin-ci
78
repository_url: https://github.com/opengisch/qgis-plugin-ci/
89
timezone: Europe/Paris

docs/configuration/options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ QGIS-Plugin-CI is best served if you use these two conventions:
3232
| `plugin_path` | **yes** | The folder where the source code is located. Shouldn't have any dash character. Defaults to: `slugify(plugin_name)`. | qgis_plugin_CI_testing |
3333
| `project_slug` | no | The *project* slug on SCM host (e.g. Github) and translation platform (e.g. Transifex).<br/>Not required when running on Travis since deduced from `$TRAVIS_REPO_SLUG`environment variable. | `qgis-plugin-ci` |
3434
| `repository_plugin_id` | no | The plugin identifier in the repository where it is published or is intended to be published. | Typically the same `plugin_id` value than on the official repository, i.e. `"3951"`. Or using a DNS prefix: `plugins.myorg.com:99999` |
35-
| `repository_url_raw` | no | | `https://raw.githubusercontent.com/opengisch/qgis-plugin-ci` for a plugin hosted on Github; `https://gitlab.com/Oslandia/qgis/oslandia/-/raw/` for a plugin hosted on gitlab. |
35+
| `repository_plugin_url` | no | Base URL for the custom plugins repository. Equivalent to and can be overridden by the `-u`/`--plugin-repo-url` CLI option. Typically, the GitHub/GitLab Pages base URL of your project. | `https://opengisch.github.io/qgis-plugin-ci/` for this project. `https://oslandia.gitlab.io/qgis/oslandia/` for this plugin hosted on public GitLab instance. |
36+
| `repository_url_raw` | no | Base URL to the source code repository. | `https://raw.githubusercontent.com/opengisch/qgis-plugin-ci` for a plugin hosted on Github; `https://gitlab.com/Oslandia/qgis/oslandia/-/raw/` for a plugin hosted on gitlab. |
3637
| `timezone` | no | The timezone for the plugin creation date. Defaults to: `UTC`. | `Europe/Paris` |
3738

3839
----

qgispluginci/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ def cli():
234234

235235
# PACKAGE
236236
if args.command == "package":
237+
# repo url from CLI option or from config file
238+
plugin_repo_url = args.plugin_repo_url or parameters.plugin_repo_url
237239
release(
238240
parameters,
239241
release_version=args.release_version,
240242
tx_api_token=args.transifex_token,
241243
allow_uncommitted_changes=args.allow_uncommitted_changes,
242-
plugin_repo_url=args.plugin_repo_url,
244+
plugin_repo_url=plugin_repo_url,
243245
plugin_repo_stylesheet=not args.no_repository_stylesheet,
244246
disable_submodule_update=args.disable_submodule_update,
245247
asset_paths=args.asset_path,

qgispluginci/parameters.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ class Parameters:
106106
The plugin identifier in the repository where it is published or is intended to be published.
107107
Defaults to None.
108108
109+
repository_plugin_url: str
110+
Base URL used to build the plugin download hyperlink in the custom plugins repository
111+
plugins.xml.
112+
Can be overriden with the CLI option -u / --plugin-repo-url.
113+
Defaults to None.
114+
109115
lrelease_path: str
110116
The path of lrelease executable
111117
@@ -120,7 +126,7 @@ class Parameters:
120126
Defaults to False
121127
122128
repository_url_raw: str
123-
Raw URL to plugin repository. Used to determine absolute URL to resources like
129+
Raw URL to source code repository. Used to determine absolute URL to resources like
124130
plugin's icon in the custom repository plugins.xml.
125131
Defaults to None.
126132
"""
@@ -229,6 +235,8 @@ def __init__(self, definition: dict[str, Any]):
229235
os.environ.get("TRAVIS_REPO_SLUG", "").split("/")[0],
230236
)
231237
self.repository_url_raw: str | None = definition.get("repository_url_raw")
238+
self.plugin_repo_url: str | None = definition.get("repository_plugin_url")
239+
232240
self.transifex_organization = definition.get(
233241
"transifex_organization", self.github_organization_slug
234242
)

test/fixtures/.qgis-plugin-ci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ timezone: Europe/Paris
1212

1313
repository_url: https://github.com/opengisch/qgis-plugin-ci/
1414
repository_plugin_id: plugins.qgis.org:99999
15+
repository_plugin_url: https://opengisch.github.io/qgis-plugin-ci/
1516

1617
#lrelease_path: /usr/local/opt/qt5/bin/lrelease

test/test_parameters.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ def test_global_parameters(self):
3636

3737
self.assertEqual("qgis_plugin_CI_testing", parameters.plugin_path)
3838
self.assertEqual("CHANGELOG.md", parameters.changelog_path)
39+
self.assertIsNone(parameters.plugin_repo_url)
40+
41+
def test_plugin_repo_url_from_config(self):
42+
"""--plugin-repo-url must be read from config file (repository_plugin_url)."""
43+
parameters = Parameters.make_from(
44+
path_to_config_file=Path("test/fixtures/.qgis-plugin-ci")
45+
)
46+
self.assertEqual(
47+
"https://opengisch.github.io/qgis-plugin-ci/", parameters.plugin_repo_url
48+
)

test/test_release.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,39 @@ def test_create_plugin_repo_disable_stylesheet(self):
352352
finally:
353353
os.chdir(original_dir)
354354

355+
def test_package_plugin_repo_url_from_config(self):
356+
"""Test plugin_repo_url from config repository_plugin_url."""
357+
self.assertEqual(
358+
"https://opengisch.github.io/qgis-plugin-ci/",
359+
self.qgis_plugin_config_params.plugin_repo_url,
360+
)
361+
362+
archive_name = self.qgis_plugin_config_params.archive_name(
363+
self.qgis_plugin_config_params.plugin_path, RELEASE_VERSION_TEST
364+
)
365+
original_dir = Path().cwd()
366+
with TemporaryDirectory() as tmp_dir:
367+
try:
368+
os.chdir(tmp_dir)
369+
xml_path = create_plugin_repo(
370+
parameters=self.qgis_plugin_config_params,
371+
release_version=RELEASE_VERSION_TEST,
372+
release_tag=RELEASE_VERSION_TEST,
373+
archive=archive_name,
374+
plugin_repo_url=self.qgis_plugin_config_params.plugin_repo_url,
375+
)
376+
content = Path(xml_path).read_text(encoding="utf-8")
377+
expected_url = (
378+
f"https://opengisch.github.io/qgis-plugin-ci/{archive_name}"
379+
)
380+
self.assertIn(
381+
expected_url,
382+
content,
383+
"Download hyperlink must be the one set in config file",
384+
)
385+
finally:
386+
os.chdir(original_dir)
387+
355388

356389
if __name__ == "__main__":
357390
unittest.main()

0 commit comments

Comments
 (0)