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.11k stars 102 forks source link

project_create: fix group lookup and allow custom remote name #784

Closed bmeneg closed 2 years ago

bmeneg commented 2 years ago

The group search logic didn't consider the fact that the GitLab API returns an alphabetical ordered list of groups within a certain group, thus when multiple subgroups were nested the value groups[0] and list[0] used in the code weren't always the expected ones.

With that, instead of looking up for the first group, we look for the last one, meaning that all subgroups found in user's namespace or wherever he has access to, is returned from the API. The match then happens with the group full path or full name, which matches first.

In case the user has access to multiple groups with ambiguous names, all possible paths are shown and lab's exits.

Also, a new flag --remote was added to allow the user to provide a remote name in case needed. lab don't add a remote by default.

Related: #782

codecov[bot] commented 2 years ago

Codecov Report

Merging #784 (f6e5f28) into master (036ff5e) will increase coverage by 0.02%. The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #784      +/-   ##
==========================================
+ Coverage   54.89%   54.92%   +0.02%     
==========================================
  Files          77       77              
  Lines        5614     5622       +8     
==========================================
+ Hits         3082     3088       +6     
- Misses       2251     2253       +2     
  Partials      281      281              
Impacted Files Coverage Δ
internal/gitlab/gitlab.go 7.41% <0.00%> (ø)
cmd/project_create.go 81.53% <85.71%> (-1.80%) :arrow_down:
cmd/label_list.go 89.18% <0.00%> (+0.95%) :arrow_up:

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 7368ada...f6e5f28. Read the comment docs.