Skip to content

Commit 1fca546

Browse files
authored
fix: properly extract tags with forward slashes (#5928)
Fixes extracting tags from the `github` source (atom feed with URLs of the form `https://github.com/<owner>/<repo>/releases/tag/<tag>`). Before, when a tag contained a slash like e.g. `sass_api/17.5.0`, everything up to and including the last slash was stripped prematurely, wrongly passing `17.5.0` instead of the full `sass_api/17.5.0` tag name when evaluating `is_tag_ignored()`. As a consequence, the [`bot.version_updates.allowed_tag_globs`](https://conda-forge.org/docs/maintainer/conda_forge_yml/#bot) config setting wouldn't work as intended.
1 parent efc7ac2 commit 1fca546

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

conda_forge_tick/update_sources.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,16 @@ def get_version(self, url: str, node_attrs: AttrsTypedDict) -> str | None:
211211
vers = []
212212

213213
for entry in data["entries"]:
214-
ver = urllib.parse.unquote(entry["link"]).split("/")[-1]
214+
ver = urllib.parse.unquote(entry["link"].split("/")[-1])
215215

216216
if is_tag_ignored(node_attrs, ver):
217217
continue
218218

219+
# Strip scope prefix (e.g. "sass_api/" from "sass_api/17.5.0") so
220+
# subsequent dev-version checks only operate on the version part.
221+
if "/" in ver:
222+
ver = ver.rsplit("/", 1)[1]
223+
219224
for prefix in self.ver_prefix_remove:
220225
if ver.startswith(prefix):
221226
ver = ver[len(prefix) :]

tests/test_upstream_versions.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,39 @@ def test_github_version_prefix(url, version, version_prefix, tmpdir):
20132013
assert gh.version_prefix == version_prefix
20142014

20152015

2016+
@mock.patch("conda_forge_tick.update_sources.feedparser.parse")
2017+
def test_github_release_tag_with_slash_respects_allowed_tag_globs(
2018+
feedparser_parse_mock: MagicMock,
2019+
):
2020+
feedparser_parse_mock.return_value = {
2021+
"bozo": 0,
2022+
"entries": [
2023+
{
2024+
"link": "https://github.com/sass/dart-sass/releases/tag/sass_api%2F17.5.0",
2025+
},
2026+
{
2027+
"link": "https://github.com/sass/dart-sass/releases/tag/sass_api%2F17.4.0",
2028+
},
2029+
],
2030+
}
2031+
2032+
node_attrs = {
2033+
"conda-forge.yml": {
2034+
"bot": {
2035+
"version_updates": {
2036+
"allowed_tag_globs": "sass_api/*",
2037+
},
2038+
},
2039+
},
2040+
}
2041+
2042+
gh = Github()
2043+
assert (
2044+
gh.get_version("https://github.com/sass/dart-sass/releases.atom", node_attrs)
2045+
== "17.5.0"
2046+
)
2047+
2048+
20162049
@pytest.mark.parametrize(
20172050
"url, feedstock_version",
20182051
[

0 commit comments

Comments
 (0)