feat: Introduce `repo remote add` command
Description
Introduce glab repo remote add command to add a GitLab project as a git remote using a project reference instead of a full URL.
- Adds
glab repo remote add <namespace/project>subcommand underglab repo remote - Remote name defaults to the first path component (
namespace/subgroup/project), matchinghub remote addpattern/ux --nameflag overrides the default remote name--protocolflag overrides the protocol
Related Issues
Resolves #8310 (closed)
How has this been tested?
Manual testing:
cd /tmp
glab repo clone gitlab-org/cli glab
Cloning into 'glab'...
remote: Enumerating objects: 56676, done.
remote: Counting objects: 100% (2432/2432), done.
remote: Compressing objects: 100% (601/601), done.
remote: Total 56676 (delta 2099), reused 2015 (delta 1826), pack-reused 54244 (from 1)
Receiving objects: 100% (56676/56676), 30.75 MiB | 13.50 MiB/s, done.
Resolving deltas: 100% (38563/38563), done.
cd glab
glab repo remote add brodock/glab
✓ Remote "brodock" added using ssh protocol.
glab repo remote add brodock/glab --name other --protocol https
✓ Remote "other" added using https protocol.
git remote -v
brodock git@gitlab.com:brodock/glab.git (fetch)
brodock git@gitlab.com:brodock/glab.git (push)
origin git@gitlab.com:gitlab-org/cli.git (fetch)
origin git@gitlab.com:gitlab-org/cli.git (push)
other https://gitlab.com/brodock/glab.git (fetch)
other https://gitlab.com/brodock/glab.git (push)
cd /tmp
git init empty-glab
cd empty-glab
glab repo remote add gitlab-org/cli --name origin
✓ Remote "origin" added using ssh protocol.Screenshots (if appropriate):
Edited by Gabriel Mazzetto