invenia / invenia/TagBotGitLab

Support MRs generated by LocalRegistry.jl

Open
#35 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
6
Forks
3
PR merge metrics
No merged PRs in 30d

Description

A few months ago, LocalRegistry.jl added the option of generating GitLab Merge Requests (MRs) to a PackageRegistry (https://github.com/GunnarFarneback/LocalRegistry.jl/pull/49).

However the generated MRs have a body/description with the following format:
```
• Registering package: Example
• Repository: gitlab.foo.com/foo/bar
• Version: v0.1.2
• Commit: abcdef
• Triggered by: @john.doe

```
We can see the fields are not separated by newline characters, but instead by `
` HTML elements. This is to workaround the fact that the MR is created via git push options and newlines are not supported there (there is a mention of this in that LocalRegistry MR https://github.com/GunnarFarneback/LocalRegistry.jl/pull/49).

TagBotGitLab fails to parse such MR body, with the following error:
```
Traceback (most recent call last):
File "/var/task/tagbotgitlab/tagbot.py", line 32, in handler
status, msg = 200, handle_event(json.loads(evt.get("body", "
{}
")))
File "/var/task/tagbotgitlab/tagbot.py", line 56, in handle_event
return handle_merge(payload)
File "/var/task/tagbotgitlab/tagbot.py", line 124, in handle_merge
release_notes = changelog.get(version, commit)
File "/var/task/gitlabchangelog/changelog.py", line 238, in get
data = self._collect_data(version, sha)
File "/var/task/gitlabchangelog/changelog.py", line 183, in _collect_data
previous = self._previous_release(version)
File "/var/task/gitlabchangelog/changelog.py", line 74, in _previous_release
cur_ver = semver.VersionInfo.parse(_strip_starting_v(version))
File "/var/task/semver.py", line 726, in parse
raise ValueError("%s is not valid SemVer string" % version)
ValueError: 0.1.2
• Commit: abcdef
• Triggered by: @john.doe
is not valid SemVer string
```
i.e. it believes the version string is `0.1.2
• Commit: abcdef
• Triggered by: @john.doe
`, since [the regex matches all characters until the end of line](https://github.com/invenia/TagBotGitLab/blob/9ed3f778f041e66c1e1671a479a365d00fffdf11/tagbotgitlab/tagbot.py#L15). Passing that string to `semver.VersionInfo.parse` rightfully produces an error.

We should change the regexes to support MRs generated both by Registrator.jl (containing newlines) and LocalRegistry.jl (containing `
` and `•`).

I'll submit a PR for this soon.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.