CLI tool for GitLab (no prerequisites required)
CLI commands for performing actions against GitLab repositories.
Follow the instructions from the releases page.
For all available commands see the command's help: gitlab-cli -h. The most common commands are documented below.
GitLab Limitation: Currently there's no way to access global labels through the API, so this tool provides a workaround to copy them.
gitlab-cli label copy -U https://gitlab.com// -t Tip: To avoid specifying
-Uand-tevery time you refer to a repository, you can use the config file to save the details of it. See Specifying a repository.
gitlab-cli label copy --from -r repoA and repoB are repository names saved in the config file.
Tip: For repositories on the same installation, you can specify the
--fromrepo asgroup/repo, as a convenience, in which case the repository is considered on the same GitLab instance as the target repo.
gitlab-cli label update -r --match --name --color --description Note:
is a Go regex string as in andis a replacement string as in .
gitlab-cli label delete -r --match Other commands can be added as needed. Feel free to open pull requests or issues.
There are 2 ways to specify a repository:
--url (-U) and --token (-t) flags (or --user (-u) and --password (-p) instead of token) with each command. This is the easiest to get started but requires a lot of typing.--repo (-r) (e.g. -r myrepo)Example:
Instead of this:
gitlab-cli label copy -U https://git.my-site.com/my_group/my_repo -t ghs93hskayou can first save the repo in the config file and refer to it by name on all subsequent commands:
gitlab-cli config repo save -r myrepo -U https://git.my-site.com/my_group/my_repo -t ghs93hska
gitlab-cli label copy -r myrepoYou can specify your GitLab login (user or email) - --user (-u) - and password - --password (-p) - instead of the token in any command, if this is easier for you. Example:
gitlab-cli config repo save -r myrepo -U https://git.my-site.com/my_group/my_repo -u my_user -p my_passThe default location of the config file is $HOME/.gitlab-cli.yaml and it is useful for saving repositories and then refer to them by their names. A sample config file looks like this:
repos:
myrepo1:
url: https://git.mysite.com/group/repo1
token: Nahs93hdl3shjf
myrepo2:
url: https://git.mysite.com/group/repo2
token: Nahs93hdl3shjf
myother:
url: https://git.myothersite.com/group/repo1
token: OA23spfwuSalosBut there's no need to manually edit this file. Instead use the config commands to modify it (see gitlab-cli config -h). Some useful config commands are:
gitlab-cli config cat - print the entire config file contentsgitlab-cli config repo ls - list all saved repositoriesgitlab-cli config repo save ... - save a repositorygitlab-cli config repo show -r - show the details of a saved repositoryYou'll need a Go dev environment.
git clone https://github.com/clns/gitlab-cli
cd gitlab-cli
git submodule --init updatego run build/build.goThis will build all the executables into the build/ directory.
You need to provide a GitLab URL and private token to be able to create temporary repositories for the tests.
GITLAB_URL="" GITLAB_TOKEN="" go test -v ./gitlabYou can spin up a GitLab instance using Docker:
…All external dependencies should be available in the vendor/ directory.
To list all dependencies run go list -f '{{.ImportPath}}:{{"\n"}} {{join .Imports "\n "}}' ./....
To vendor a package run git submodule add https://github.com/google/go-github vendor/github.com/google/go-github.
No open issues yet, or sync has not completed.