Lab wraps Git or Hub, making it simple to clone, fork, and interact with repositories on GitLab

git + = gitlab Build Status Go Report Card codecov Join the chat at https://gitter.im/labcli CC0 License Donate

Lab wraps Git, making it simple to clone, fork, and interact with repositories on GitLab, including seamless workflows for creating merge requests, issues and snippets.

$ lab clone gitlab-com/infrastructure

# expands to:
$ git clone [email protected]:gitlab-com/infrastructure

Inspiration

The hub tool made my life significantly easier and still does! lab is heavily inspired by hub and attempts to provide a similar feel.

Installation

Dependencies

  • git

Homebrew

brew install lab

NixOS

nix-env -f '
   
    ' -iA gitAndTools.lab

   

Scoop

scoop bucket add zaquestion https://github.com/zaquestion/scoop-bucket.git
scoop install lab

Alpine

apk add lab

Bash

Installs lab into /usr/local/bin/

curl -s https://raw.githubusercontent.com/zaquestion/lab/master/install.sh | sudo bash

NOTE: Please take care when executing scripts in this fashion. Make sure you trust the developer providing the script and consider peeking at the install script itself (ours is pretty simple ;)

PreBuilt Binaries

Head to the releases page and download your preferred release

Source

Required

git clone [email protected]:zaquestion/lab
cd lab
go install -ldflags "-X \"main.version=$(git  rev-parse --short=10 HEAD)\"" .

or

make install

Tests

See the contribution guide.

Configuration

lab needs your GitLab information in order to interact with to your GitLab instance. There are several ways to provide this information to lab:

  1. environment variables: CI_PROJECT_URL, CI_JOB_TOKEN, GITLAB_USER_LOGIN;
    • Note: these are meant for when lab is running within a GitLab CI pipeline
    • If all of these variables are set, the config files will not be updated.
    • If all of these variables are set, these take precedence over all other values.
  2. environment variables: LAB_CORE_HOST, LAB_CORE_TOKEN;
    • If these variables are set, the config files will not be updated.
    • For example to use gitlab.com do: export LAB_CORE_HOST="https://gitlab.com"
  3. local configuration file in Tom's Obvious, Minimal Language (TOML): ./lab.toml;
    • No other config files will be used as overrides if a local configuration file is specified
  4. user-specific configuration file in TOML: ~/.config/lab/lab.toml.
  5. work-tree configuration file in TOML: .git/lab/lab.toml. The values in this file will override any values set in the user-specific configuration file.

If no suitable config values are found, lab will prompt for your GitLab information and save it into ~/.config/lab/lab.toml. For example:

$ lab
Enter default GitLab host (default: https://gitlab.com):
Enter default GitLab token:

Command-specific flags can be set in the config files.

[mr_show]
  comments = true # sets --comments on 'mr show' commands

Completions

lab provides completions for Bash, Elvish, Fish, Oil, Powershell, Xonsh and Zsh. Scripts can be directly sourced (though using pre-generated versions is recommended to avoid shell startup delay):

# bash (~/.bashrc)
source <(lab completion)

# elvish (~/.elvish/rc.elv)
eval (lab completion|slurp)

# fish (~/.config/fish/config.fish)
lab completion | source

# oil
source <(lab completion)

# powershell (~/.config/powershell/Microsoft.PowerShell_profile.ps1)
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
lab completion | Out-String | Invoke-Expression

# xonsh (~/.config/xonsh/rc.xsh)
COMPLETIONS_CONFIRM=True
exec($(lab completion xonsh))

# zsh (~/.zshrc)
source <(lab completion zsh)

What about GLab?

Both glab and lab are open-source tools with the same goal of bringing GitLab to your command line and simplifying the developer workflow. In many ways lab is to hub, what glab is to gh.

lab aims to feel familiar to a git user and leverages git to power many of it's commands. glab will feel more familiar to gh users and in turn is more interactive and likely more beginner friendly for that reason.

$ lab
Enter GitLab host (default: https://gitlab.com):

CC0
To the extent possible under law, Zaq? Wiedmann has waived all copyright and related or neighboring rights to Lab. This work is published from: United States.

Comments
  • Accept self signed certificates

    Accept self signed certificates

    Hi, is it possible to configure lab to accept self signed certificates?

    This is the error: mrList.go:38: Get https:/api/v4/projects/<project>: x509: certificate signed by unknown authority

  • cmd: Pipe output through pager in terminals

    cmd: Pipe output through pager in terminals

    Replicate git's behavior of piping output through a pager when it doesn't fit a single screen. This is not only more convenient than piping into less on the command line, but preserves terminal features like colored output as well.

    I do have a local follow-up to add a global --no-pager option like git as well, if that's wanted (not sure that's the case, so leaving it out right now)

  • Alternative syntax for lab mr create

    Alternative syntax for lab mr create

    The lab mr create would be much more helpful if the following options are available.

    GitLab MR property | options --------------------|--------- source_branch| -s <source-branch-name> target_branch|-t <target-branch-name>

  • lab ci wait

    lab ci wait

    I don't know wether or not this is possible, but it would be nice to have a ci command that simpy waits for the current pipeline to finish and then exits with status code 0 for success, and 1 for failure. This would allow scripting of several pipelines that need to be run in a specific order. I know you can trigger builds inside a pipeline, but we need it the other way - like a listener.

    This would allow something like this:

    cd /whatever/docker-base
    lab ci create
    lab ci wait
    cd /whatever/docker-project-that-uses-docker-base
    # or maybe
    lab ci create --wait
    cd /whatever/another-docker-project-that-uses-docker-base
    # or maybe
    lab ci create
    lab ci trace --exit-on-finish
    ...
    
  • cmd/mr_checkout: check existing remotes before creating one

    cmd/mr_checkout: check existing remotes before creating one

    In case tacking is enabled lab mr checkout -t, a new remote is created with the name of the MR author's name without checking if the already available remotes matches the one from which the MR was checked-out. A particular case where it happens constantly is in the branching development model: developers use a single repo to push their work as branches.

    This patch change the code behavor by first checking if any of the existent remotes has the same path as the source MR project before creating a new remote. If no remote is found, then create a new one with the MR author's name.

    Signed-off-by: Bruno Meneguele [email protected]

    Related: #774

  • nil pointer since 0.18.0

    nil pointer since 0.18.0

    After updating from 0.17.2 to 0.18.0 creating a merge request triggers a nil pointer.

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe85f3a]
    goroutine 1 [running]:
    github.com/spf13/viper.(*Viper).find(0x0, 0xc000471a60, 0xd, 0x1, 0xc000471a60, 0xd)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/viper.go:1027 +0x3a
    github.com/spf13/viper.(*Viper).Get(0x0, 0xc000471a60, 0xd, 0x2, 0x2)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/viper.go:728 +0x85
    github.com/spf13/viper.(*Viper).GetStringSlice(0x0, 0xc000471a60, 0xd, 0x10cc4ed, 0x5, 0xc000471a60)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/viper.go:865 +0x3f
    github.com/zaquestion/lab/cmd.flagConfig.func1(0xc0004c7b80)
    	/home/travis/gopath/src/github.com/zaquestion/lab/cmd/util.go:45 +0x48b
    github.com/spf13/pflag.(*FlagSet).VisitAll(0xc000660700, 0x11c37a0)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/flag.go:290 +0x94
    github.com/zaquestion/lab/cmd.flagConfig(0xc000660700)
    	/home/travis/gopath/src/github.com/zaquestion/lab/cmd/util.go:31 +0x37
    github.com/zaquestion/lab/cmd.LabPersistentPreRun(0x18c0280, 0xc0006756a0, 0x0, 0x2)
    	/home/travis/gopath/src/github.com/zaquestion/lab/cmd/util.go:341 +0x39
    github.com/spf13/cobra.(*Command).execute(0x18c0280, 0xc000675680, 0x2, 0x2, 0x18c0280, 0xc000675680)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:834 +0x231
    github.com/spf13/cobra.(*Command).ExecuteC(0x18bb120, 0xc0000320a0, 0x5, 0x5)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:958 +0x375
    github.com/spf13/cobra.(*Command).Execute(...)
    	/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:895
    github.com/zaquestion/lab/cmd.Execute()
    	/home/travis/gopath/src/github.com/zaquestion/lab/cmd/root.go:222 +0x196
    main.main()
    	/home/travis/gopath/src/github.com/zaquestion/lab/main.go:28 +0x93
    
  • updated shell completion

    updated shell completion

    Had another go at what i originally extracted from the cobra zsh PR: https://github.com/rsteube/cobra-zsh-gen This brings lab back to cobra (no fork) and makes the completion less cryptic as it's all go code.

    • adds dependency to https://github.com/rsteube/cobra-zsh-gen
    • adds dependency to https://github.com/src-d/go-git (seemed resonable to me as this makes git handling a bit easier than invoking the shell, but can change that if it's a bad idea)

    Needs some good testing (looks ok so far).

    fixes #333 fixes #367

  • lab mr complains that gitlab project not found

    lab mr complains that gitlab project not found

    I am kind of lost.

    I cloned a self-hosted repo on gitlab and I am trying to create a merge request or list all merge requests, but I am getting:

    [dpetrov@macbook-pro /tmp/apps (master)]$ lab mr list
    2018/03/06 22:40:58 mrList.go:38: gitlab project not found
    

    Is there something that i am missing?

    Thanks

  • Add merge-request option for

    Add merge-request option for "Merge when pipeline succeeds"

    It would be helpful if lab would provide an option to enable the "Merge when pipeline succeeds" Option, especially in the automation context, where we use lab.

    A push option named merge_request.merge_when_pipeline_succeeds does exist for that matters.

  • Open the current merge request with lab mr b

    Open the current merge request with lab mr b

    This is a work in progress.

    The current code fails with the following error:

    ../../go/src/github.com/zaquestion/lab/cmd/mr_browse.go:46:17: unknown field 'SourceBranch' in struct literal of type "github.com/zaquestion/lab/vendor/github.com/xanzy/go-gitlab".ListProjectMergeRequestsOptions
    

    There is indeed a ListProjectMergeRequestsOptions.SourceBranch here: https://github.com/xanzy/go-gitlab/blob/master/merge_requests.go#L262

    Unfortunately, I have a different file in vi vendor/github.com/xanzy/go-gitlab/merge_requests.go...

  • Review with quick actions

    Review with quick actions

    This is the second part of the change to unify the calls made when approving/commenting on an MR.

    The new code removes the usage of the merge_request/approve API and instead uses the /approve and /unapprove notes API quick actions. Fixes: #708

  • lab issue create mr

    lab issue create mr

    Hi, I saw that when you create an Issue it is not possible to create an MR, which instead you can do through Gitlab's web interface, as shown in the image below. Is this features still not yet available or will it not be implemented?

    immagine

  • project list --all command option does not return all the projects anymore

    project list --all command option does not return all the projects anymore

    Since version 0.25.0, the --all option of the project list command it not working as expected.

    # Expected result, working with 0.24.0
    ❯ LAB_CORE_HOST="https://gitlab.com" LAB_CORE_TOKEN=${GITLAB_TOKEN} ./lab-0.24.0 project list --member --all | wc -l 
    280
    # Current result
    ❯ LAB_CORE_HOST="https://gitlab.com" LAB_CORE_TOKEN=${GITLAB_TOKEN} ./lab-0.25.0 project list --member --all | wc -l
    100
    
  • `lab mr create` from local branch

    `lab mr create` from local branch

    I'm using both lab and Github cli and one thing that I find very convenient with gh is the ability to create a pull request from a local branch that has not been pushed yet to a remote.

    Would it be possible with lab ?

  • create command to handle approval rules

    create command to handle approval rules

    We need a new command to handle the basics of merge-request approval rules. Some of the features I would like to see are:

    • [ ] show approval rules of a certain mr
    • [ ] add a new approval rule
    • [ ] delete an approval rule

    The ACL should be already controlled by GitLab itself.

  • `lab mr merge` does not respect delete source branch

    `lab mr merge` does not respect delete source branch

    I create an mr using lab mr create --remove-source-branch and it shows that the source branch will be removed.

    Then I do lab mr merge and then it no longer shows it will remove the source branch.

    Using lab version:

    $ lab --version
    lab version 0.24.0
    
A Git RPC service for handling all the git calls made by GitLab
A Git RPC service for handling all the git calls made by GitLab

Quick Links: Roadmap | Want to Contribute? | GitLab Gitaly Issues | GitLab Gitaly Merge Requests | Gitaly is a Git RPC service for handling all the gi

Nov 13, 2021
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI
A Simple and Comprehensive Vulnerability Scanner for Container Images, Git Repositories and Filesystems. Suitable for CI

A Simple and Comprehensive Vulnerability Scanner for Containers and other Artifacts, Suitable for CI. Abstract Trivy (tri pronounced like trigger, vy

Jan 9, 2023
Sync tags in your git repository and a changelog in Keep a Changelog format with releases of your GitLab project.

Automatic GitLab releases Sync tags in your git repository and a changelog in Keep a Changelog format with releases of your GitLab project. Features:

Nov 12, 2022
A tool to monitor git repositories and automatically pull & push changes

git-o-matic A tool to monitor git repositories and automatically pull & push changes Installation Packages & Binaries Arch Linux: gitomatic Binaries f

Dec 20, 2022
SQL interface to git repositories, written in Go. https://docs.sourced.tech/gitbase

gitbase gitbase, is a SQL database interface to Git repositories. This project is now part of source{d} Community Edition, which provides the simplest

Dec 25, 2022
A simple cli tool for switching git user easily inspired by Git-User-Switch
A simple cli tool for switching git user easily inspired by Git-User-Switch

gitsu A simple cli tool for switching git user easily inspired by Git-User-Switch Installation Binary releases are here. Homebrew brew install matsuyo

Dec 31, 2022
Git with a cup of tea, painless self-hosted git service
Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023
ReGit: A Tiny Git-Compatible Git Implementation written in Golang

ReGit is a tiny Git implementation written in Golang. It uses the same underlying file formats as Git. Therefore, all the changes made by ReGit can be checked by Git.

Oct 31, 2022
Removes unnecessarily saved git objects to optimize the size of the .git directory.

Git Repo Cleaner Optimizes the size of the .git directory by removing all of the files that are unnecessarily-still-saved as part of the git history.

Mar 24, 2022
Gum - Git User Manager (GUM) - Switch between git user profiles
Gum - Git User Manager (GUM) - Switch between git user profiles

Git User Manager (GUM) Add your profile info to config.yaml Build project: go bu

Feb 14, 2022
Git-now-playing - Git commits are the new AIM status messages

git-now-playing git-now-playing is an attempt to bring some of the panache of th

Apr 4, 2022
Tfcmt-gitlab is a CLI command to parse and notify Terraform execution results

Tfcmt-gitlab is a CLI command to parse and notify Terraform execution results. This command supports GitLab as a CI and notification platform.

Dec 23, 2022
A really smart bot that connects with your email, discord, telegram and gitlab
A really smart bot that connects with your email, discord, telegram and gitlab

SmarttyBot The smartest multiplatform bot SmarttyBot is a multiplatform bot that uses natural language to execute functions using discord, telegram, e

Jun 2, 2022
A simple tool to help apply changes across many GitHub repositories simultaneously
A simple tool to help apply changes across many GitHub repositories simultaneously

A simple tool to help apply changes across many GitHub repositories simultaneously

Dec 22, 2022
Gitlab include draftsman in golang
Gitlab include draftsman in golang

Gitlab include draftsman WIP Утилита, которая рисует graph include'ов из gitlab-ci Как работает пока: Считывает из app.env файла(который должен быть в

Oct 31, 2021
Find trending repositories on GitHub
Find trending repositories on GitHub

octotrends.com A niftly little tool I wrote to try and find repos and languages that are rapidly growing on GitHub. Growth rates are based on % growth

Jun 14, 2022
Simple git hooks written in go that installs globally to your machine

Go-hooks Simple git hooks written in go that installs globally to your machine Install curl -fsSL

Oct 19, 2022
🥄A simple generator for semantic git messages.

?? Tablespoon EXPERIMENTAL PREVIEW A simple generator for semantic git messages. Installation | Contributing Tablespoon is a simple generator which ca

Jul 22, 2022
Fast and powerful Git hooks manager for any type of projects.
Fast and powerful Git hooks manager for any type of projects.

Lefthook The fastest polyglot Git hooks manager out there Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects. Fast. I

Jan 4, 2023