Skip to content

Commit

Permalink
feat(gitlab): label issue and mr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
reitzig committed Oct 1, 2024
1 parent bf6ce75 commit 3870e03
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nice-dev-refs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ then type any of the following:
wiki page (& heading), gist (& file & line),
advisories, enterprises
- **GitLab**: repository, commit,
issue (& search),
merge request (& search),
issue (& comment, search),
merge request (& comment, search),
file (& line), snippet,
heading in rendered file
- **Jenkins**
Expand Down
2 changes: 1 addition & 1 deletion scripts/label_for_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def determine_label(input_url: str) -> str:
elif m := re.search(
r"^https://[^/]*git(hub|lab)[^/]*/(?P<project>[^/]+)/(?P<repo>[^/]+)(/-)?/("
r"((?P<type>issues|pull|discussions|merge_requests)/(?P<number>\d+)"
r"(#((issue|discussion)comment-|discussion_r)(?P<comment_id>\d+))?)"
r"(#((issue|discussion)comment-|discussion_r|note_)(?P<comment_id>\d+))?)"
r"|(releases/tag/(?P<release_tag>[^/#?]+))"
r")",
input_url,
Expand Down
22 changes: 22 additions & 0 deletions test/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ def test_should_label_issue() -> None:
assert_that(label).is_equal_to("my-account/some-repo#77")


def test_should_label_issue_comment() -> None:
# Given:
url = "https://gitlab.some.org/my-account/some-repo/-/issues/77#note_42"

# When:
label = determine_label(url)

# Then:
assert_that(label).is_equal_to("my-account/some-repo#77.42")


def test_should_label_issue_list_by_label() -> None:
# Given:
url = (
Expand Down Expand Up @@ -142,6 +153,17 @@ def test_should_label_mr() -> None:
assert_that(label).is_equal_to("my-account/some-repo!119")


def test_should_label_mr_comment() -> None:
# Given:
url = "https://gitlab.some.org/my-account/some-repo/-/merge_requests/119#note_77"

# When:
label = determine_label(url)

# Then:
assert_that(label).is_equal_to("my-account/some-repo!119.77")


def test_should_label_mr_list_by_labels() -> None:
# Given:
url = "https://gitlab.some.org/my-account/some-repo/-/merge_requests?label_name%5B%5D=Doing"
Expand Down

0 comments on commit 3870e03

Please sign in to comment.