fix(repo clone): fix --with-shared behaviour
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
Description
glab repo clone --group <group name>
was documented as not cloning any projects shared to the target group, by default.
However, the actual default behaviour was the opposite: glab repo clone --group
cloned shared projects. Also, explicitly passing --with-shared=false
did nothing. For more details, see #7655 (closed).
This MR allows for a value of false
to be passed by the user; but it also changes the default value of --with-shared
to true
to avoid breaking any existing workflows that might depend on this behaviour. I also updated the docs using make gen-docs
to reflect the change in the --with-shared
parameter's default value.
Related Issues
Resolves #7655 (closed)
How has this been tested?
- I ran
make test
, everything passed. - I ran
make
to build a new version ofglab
- I set an alias of
patchglab
to my new version of glab so I can test it alongside the version I have installed. - I ran
patchglab repo clone --with-shared=false --include-subgroups=false --paginate --group gitlab-com/marketing
to check if we can now filter out shared projects. (gitlab-com/marketing
has 3 projects directly within it (2 archived/"inactive") - ignoring subgroups - and 1 project shared to it.)
$ patchglab repo clone --with-shared=false --include-subgroups=false --paginate --group gitlab-com/marketing
Cloning into 'onboarding'...
remote: Enumerating objects: 1089, done.
remote: Counting objects: 100% (154/154), done.
remote: Compressing objects: 100% (91/91), done.
remote: Total 1089 (delta 79), reused 41 (delta 41), pack-reused 935 (from 1)
Receiving objects: 100% (1089/1089), 202.70 KiB | 1.62 MiB/s, done.
Resolving deltas: 100% (388/388), done.
Cloning into 'online-growth'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 80 (delta 25), reused 49 (delta 13), pack-reused 0 (from 0)
Receiving objects: 100% (80/80), 9.70 KiB | 1.94 MiB/s, done.
Resolving deltas: 100% (25/25), done.
Cloning into 'content-marketing'...
remote: Enumerating objects: 76, done.
remote: Counting objects: 100% (76/76), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 76 (delta 21), reused 64 (delta 13), pack-reused 0 (from 0)
Receiving objects: 100% (76/76), 12.26 KiB | 2.45 MiB/s, done.
Resolving deltas: 100% (21/21), done.
✓ gitlab-com/marketing/onboarding
✓ gitlab-com/marketing/online-growth
✓ gitlab-com/marketing/content-marketing
- Since this only cloned 3 repos (and not the shared project,
tfir-gitlab-media-collaboration
), we can see that the change allows us to avoid cloning shared projects. - To demonstrate the old default behaviour still works, running it in a different folder with no parameter:
$ patchglab repo clone --include-subgroups=false --paginate --group gitlab-com/marketing
Cloning into 'onboarding'...
remote: Enumerating objects: 1089, done.
remote: Counting objects: 100% (154/154), done.
remote: Compressing objects: 100% (91/91), done.
remote: Total 1089 (delta 79), reused 41 (delta 41), pack-reused 935 (from 1)
Receiving objects: 100% (1089/1089), 202.70 KiB | 1.58 MiB/s, done.
Resolving deltas: 100% (388/388), done.
Cloning into 'tfir-gitlab-media-collaboration'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (6/6), done.
Cloning into 'online-growth'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (63/63), done.
remote: Total 80 (delta 25), reused 49 (delta 13), pack-reused 0 (from 0)
Receiving objects: 100% (80/80), 9.70 KiB | 1.62 MiB/s, done.
Resolving deltas: 100% (25/25), done.
Cloning into 'content-marketing'...
remote: Enumerating objects: 76, done.
remote: Counting objects: 100% (76/76), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 76 (delta 21), reused 64 (delta 13), pack-reused 0 (from 0)
Receiving objects: 100% (76/76), 12.26 KiB | 2.45 MiB/s, done.
Resolving deltas: 100% (21/21), done.
✓ gitlab-com/marketing/onboarding
✓ arnieswap/tfir-gitlab-media-collaboration
✓ gitlab-com/marketing/online-growth
✓ gitlab-com/marketing/content-marketing
- Since this also gets the shared project (and this was how
glab
has previously worked, despite documentation), this maintains the existing default behaviour.
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms) -
Test gap
Edited by 🤖 GitLab Bot 🤖