zaquestion / lab

Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab
https://zaquestion.github.io/lab
Creative Commons Zero v1.0 Universal
1.1k stars 103 forks source link

mr list: Milestone exact match fix #825

Closed prarit closed 2 years ago

prarit commented 2 years ago

The following error occurs with 'lab mr list' when looking for MRs with a specific milestone:

[prarit@prarit rhel-8]$ lab mr list --state merged --milestone 'RHEL-8.7.0' 2022/04/09 08:58:45 ERROR: mr_list.go:120: Milestone 'RHEL-8.7.0' is ambiguous

There are two milestones with similar names in the project:

[prarit@prarit rhel-8]$ lab milestone list | grep "8.7.0" RHEL-8.7.0-test - Red Hat Enterprise Linux 8, release 8.7.0 RHEL-8.7.0 - Red Hat Enterprise Linux 8.7.0 release

The lab error occurs because the GitLab API List Milestones "Search" option does not do exact matching and returns a list of possible matching milestones. Since no one else has hit this error it seems safe to look for and return an exact match if the API returns multiple milestones.

Look for an exact match when searching for a milestone.

Signed-off-by: Prarit Bhargava prarit@redhat.com

zampierilucas commented 2 years ago

Instead of checking it agains the user input, you could change line 913 to title instead of search, that would make GitLab ensures exact match instead of us.

bmeneg commented 2 years ago

Instead of checking it agains the user input, you could change line 913 to title instead of search, that would make GitLab ensures exact match instead of us.

@prarit I agree with Lucas. GitLab already offers the exact match logic with "Title" instead of "Search". So changing it in &gitlab.ListMilestonesOptions and removing the "ambiguity" conditional seems better.

prarit commented 2 years ago

Fixed. Sorry for the delay.

codecov[bot] commented 2 years ago

Codecov Report

Merging #825 (68c2643) into master (73bada2) will decrease coverage by 0.12%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master     #825      +/-   ##
==========================================
- Coverage   56.30%   56.17%   -0.13%     
==========================================
  Files          77       77              
  Lines        5760     5771      +11     
==========================================
- Hits         3243     3242       -1     
- Misses       2227     2238      +11     
- Partials      290      291       +1     
Impacted Files Coverage Δ
internal/gitlab/gitlab.go 7.64% <0.00%> (ø)
cmd/fork.go 57.89% <0.00%> (-5.27%) :arrow_down:
cmd/mr_create.go 71.79% <0.00%> (-2.20%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 73bada2...68c2643. Read the comment docs.