<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Clement Sam</title>
    <description>The latest articles on DEV Community by Clement Sam (@profclems).</description>
    <link>https://dev.to/profclems</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F294237%2Ff02fc9da-51b5-4dfa-8ba9-604811fb4684.jpeg</url>
      <title>DEV Community: Clement Sam</title>
      <link>https://dev.to/profclems</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/profclems"/>
    <language>en</language>
    <item>
      <title>Take GitLab to the Command Line</title>
      <dc:creator>Clement Sam</dc:creator>
      <pubDate>Wed, 02 Dec 2020 15:22:07 +0000</pubDate>
      <link>https://dev.to/profclems/take-gitlab-to-the-command-line-1ccl</link>
      <guid>https://dev.to/profclems/take-gitlab-to-the-command-line-1ccl</guid>
      <description>&lt;p&gt;This guide features &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt;, an open-source GitLab CLI tool I maintain.&lt;/p&gt;

&lt;p&gt;In this quickstart guide, you’ll learn &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt;: find out what the tool is used for, how to set it up, and how to use it.&lt;/p&gt;

&lt;p&gt;If you’re a GitLab user, you’re obviously aware that you need to switch to the web browser in order to perform various actions like creating issues, merge requests, viewing pipeline logs, etc on your GitLab repository. &lt;br&gt;
With the &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt;, you can execute many of these actions without leaving the command-line interface. &lt;/p&gt;

&lt;h1&gt;
  
  
  Setting up &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;To get started, simply visit the &lt;a href="https://github.com/profclems/glab#installation" rel="noopener noreferrer"&gt;installation page&lt;/a&gt; and find instructions on how to install &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt; for your operating system. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt; can be installed via several package managers such as homebrew for macOS, Scoop for Windows, and other platform-specific package managers for Linux including Snapcraft.&lt;/p&gt;

&lt;p&gt;Below are snapshots of installation instructions for each supported platform:&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows:
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;scoop &lt;span class="nb"&gt;install &lt;/span&gt;glab


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  macOS:
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;glab


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Linux
&lt;/h2&gt;
&lt;h3&gt;
  
  
  SnapCraft
&lt;/h3&gt;

&lt;p&gt;Make sure you have snap installed on your Linux Distro (&lt;a href="https://snapcraft.io/docs/installing-snapd" rel="noopener noreferrer"&gt;https://snapcraft.io/docs/installing-snapd&lt;/a&gt;).&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;snap &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--edge&lt;/span&gt; glab
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;snap connect glab:ssh-keys


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Debian/Ubuntu Linux:
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; glab_&lt;span class="k"&gt;*&lt;/span&gt;_linux_amd64.deb


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Fedora/Centos Linux:
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum localinstall glab_&lt;span class="k"&gt;*&lt;/span&gt;_linux_amd64.rpm


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Arch Linux:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt; is available through the &lt;a href="https://aur.archlinux.org/packages/gitlab-glab-bin/" rel="noopener noreferrer"&gt;gitlab-glab-bin&lt;/a&gt; and &lt;a href="https://aur.archlinux.org/packages/gitlab-glab/" rel="noopener noreferrer"&gt;gitlab-glab&lt;/a&gt; packages on the AUR &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;yay &lt;span class="nt"&gt;-S&lt;/span&gt; gitlab-glab


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or with pacman&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; gitlab-glab-bin


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  KISS Linux:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt; is available on the &lt;a href="https://github.com/kisslinux/community" rel="noopener noreferrer"&gt;KISS Linux Community Repo&lt;/a&gt; as &lt;code&gt;gitlab-glab&lt;/code&gt;. If you already have the community repo configured in your &lt;code&gt;KISS_PATH&lt;/code&gt; you can install &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt; through your terminal:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;kiss b gitlab-glab &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; kiss i gitlab-glab


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Authentication
&lt;/h1&gt;

&lt;p&gt;After installing &lt;a href="https://github.com/profclems/glab" rel="noopener noreferrer"&gt;&lt;code&gt;glab&lt;/code&gt;&lt;/a&gt;, you’ll need to authenticate your account with a Personal Access Token. &lt;/p&gt;

&lt;p&gt;Get a GitLab access token at &lt;a href="https://gitlab.com/profile/personal_access_tokens" rel="noopener noreferrer"&gt;https://gitlab.com/profile/personal_access_tokens&lt;/a&gt; or &lt;a href="https://gitlab.example.com/profile/personal_access_tokens" rel="noopener noreferrer"&gt;https://gitlab.example.com/profile/personal_access_tokens&lt;/a&gt; if it is a self-hosted instance and run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;glab auth login


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This starts an interactive set-up like the screenshot below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fojlm3wdiglucc4xtp2xz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fojlm3wdiglucc4xtp2xz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are other authentication options for non-interactive mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;authenticate against gitlab.com by reading the token from a file
```sh
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;$ glab auth login --stdin &amp;lt; myaccesstoken.txt&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 - authenticate against a self-hosted GitLab instance by reading from a file
```sh


$ glab auth login --hostname salsa.debian.org --stdin &amp;lt; myaccesstoken.txt


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;authenticate with token and hostname (Not recommended for shared environments)
```sh
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;$ glab auth login --hostname gitlab.example.org --token xxxxx&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

# [`glab`](https://github.com/profclems/glab) Core Commands

[`glab`](https://github.com/profclems/glab) provides these core commands to interact with GitLab API and repositories
```sh


  alias:       Create, list and delete aliases
  api:         Make an authenticated request to GitLab API
  auth:        Manage glab{% raw %}`s authentication state
  check-update: Check for latest glab releases
  completion:  Generate shell completion scripts
  config:      Set and get glab settings
  help:        Help about any command
  issue:       Work with GitLab issues
  label:       Manage labels on remote
  mr:          Create, view and manage merge requests
  pipeline:    Manage pipelines
  release:     Manage GitLab releases
  repo:        Work with GitLab repositories and projects
  user:        Interact with user
  version:     show glab version information

```

Each core command has nested/child commands where you can specify the operation you want to perform — such as `glab repo clone` or `glab issue list`. 

We’ll look at some of the commands in more detail in the upcoming sections.


# Repository Commands

Cloning a repo with the `glab` is easier than using the git command. To clone, all you have to do is execute the command in the following format:

```sh
$ glab repo clone NAMESPACE/REPO
```
To clone your own repository, save yourself time by omitting the `NAMESPACE`.
You no longer need to copy the clone url before cloning a repository:
```
$ glab repo clone glab-cli/test
```
`glab` will clone using your preferred `git_protocol` set during authentication or you can set/update with:
```sh
$ glab config set --global git_protocol {ssh | https}
```
Specify `--host` flag to make it host-specific.


You can also download an archive of an existing repository easily from the command line. Try:
```sh
$ glab repo archive profclems/glab --format tar.gz
```
The `--format` flag allows you to specify the format in which you want the archive downloaded. 
Supports formats: `{tar.gz | tar.bz2 | tbz | tbz2 | tb2 | bz2 | tar | zip}`

You can also create a new GitLab repository from the command line. Assuming you have a local git repository or project you would want to create a new GitLab repository from, just `cd` into the project root directory and run:

```sh
$ glab repo create --public
```
If you don’t specify the --public option, a private repository will be created by default. 
If you’d like to create the repo under a different namespace, you’ll need to use the following syntax: `glab repo create namespace/repo`

# Merge Requests and Issues Workflow
Creating an issue, working on the issue and creating a merge request for your team to review can now be done on the terminal interactively with `glab mr create`.

`glab` supports issue and merge request templates and allows you to select the template to apply and edit. It automatically loads and caches the project labels and opens the multiselect prompt to select the labels to add.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fm59bb741cwpg5xyfv5m.png)

Below is the full output
```sh
$ glab mr create
? Choose a template  [Use arrows to move, type to filter]
&amp;gt; Default
  Open a blank merge request

? Description &amp;lt;Received&amp;gt;
? Do you want to add labels? Yes
? Select Labels  [Use arrows to move, space to select, &amp;lt;right&amp;gt; to all, &amp;lt;left&amp;gt; to none, type to filter]
&amp;gt; [ ]  Doing
  [x]  To Do
  [x]  bug
  [ ]  frontend
  [ ]  label1
  [ ]  label2
  [ ]  none

Creating merge request for fix-ci-br into (master) in glab-cli/test

!1 CI failure occured (fix-ci-br)
 https://gitlab.com/glab-cli/test/-/merge_requests/1

```

You can also create a merge request for an issue as done on the GitLab UI from the command line with:
```sh
$ glab mr for &amp;lt;issueID&amp;gt;
```
This is create a new draft merge request for the issue and also create a new branch using the title of the issue.

Assuming our first issue has the title "CI failure occurred":

```sh
→ glab mr for 1

!2 Draft: Resolve "CI failure occurred" (1-ci-failure-occurred)
 https://gitlab.com/glab-cli/test/-/merge_requests/2

```
You can then checkout to the merge request branch with `glab mr checkout &amp;lt;id&amp;gt;`

```sh
$ glab mr checkout 2
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 198 bytes | 2.00 KiB/s, done.
From gitlab.com:glab-cli/test
 * [new ref]         refs/merge-requests/2/head -&amp;gt; 1-ci-failure-occured

```

# Configuration

`glab` follows the XDG Base Directory [Spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html): global configuration file is saved at `~/.config/glab-cli`. Local configuration file is saved at the root of the working git directory and automatically added to `.gitignore`.

**To set configuration globally**

```sh
$ glab config set --global editor vim
```

**To set configuration for current directory (must be a git repository)**

```sh
$ glab config set editor vim
```

**To set configuration for a specific host**

Use the `--host` flag to set configuration for a specific host. This is always stored in the global config file with or without the `global` flag.

```sh
$ glab config set editor vim --host gitlab.example.org
```

# GitLab CI
The GitLab CI is a very important feature which comes as part of GitLab.

With `glab`, you no longer need to hop from IDE or command Line to the web to view job logs or watch the pipeline as it runs when you can easily do that from your command line.

`glab` provides `glab pipeline` command which has several nested commands to help you manage your GitLab CI environment. 
```sh
  ci:         Work with GitLab CI pipelines and jobs
  delete:     Delete a pipeline
  list:       Get the list of pipelines
  run:        Create a new pipeline run
  status:     View a running pipeline on current or other branch specified

```

You can watch the CI pipeline as it runs directly from your command line with `glab pipeline ci view` and trace job logs with `glab pipeline ci trace`

```sh
$ glab pipeline ci trace

Searching for latest pipeline on dev...
Getting jobs for pipeline 222781675...
? Select pipeline job to trace: deploy-staging (879211827) - success
Getting job trace...
Showing logs for deploy-staging job #879211827
Running with gitlab-runner 13.3.1 (738bbe5a)
  on Simeds Back-end CI Runner JyMs7scA
Preparing the "docker" executor
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image 
....
....
Saving cache
Creating cache dev...
WARNING: vendor: no matching files                 
Created cache
Archive is up to date!                             
Job succeeded
```

# Conclusion

[`glab`](https://github.com/profclems/glab) offers a lot of core and subcommands that are very useful to GitLab users which we only looked at the basics. 
I would recommend you integrate the tool into your workflow and make it a habit, as it clearly does save some time managing your repository. 

Check the [documentation](glab.readthedocs.org) for all the commands available and their usage.

If you encounter any issue or want to suggest a feature, open an issue at https://github.com/profclems/glab/issues

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>git</category>
      <category>gitlab</category>
      <category>contributorswanted</category>
    </item>
    <item>
      <title>GLab v1.9.0 released!</title>
      <dc:creator>Clement Sam</dc:creator>
      <pubDate>Mon, 17 Aug 2020 00:33:47 +0000</pubDate>
      <link>https://dev.to/profclems/glab-v1-9-0-released-3100</link>
      <guid>https://dev.to/profclems/glab-v1-9-0-released-3100</guid>
      <description>&lt;p&gt;Just released v1.9.0 of glab (a GitLab Cli tool) with new cool features including WATCHING A RUNNING PIPELINE AND VIEWING A JOB'S TRACE/LOG DIRECTLY FROM YOUR CLI. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/profclems/glab"&gt;https://github.com/profclems/glab&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>glab</category>
      <category>github</category>
      <category>contributorswanted</category>
    </item>
    <item>
      <title>GLab: A Gitlab CLI tool</title>
      <dc:creator>Clement Sam</dc:creator>
      <pubDate>Sat, 01 Aug 2020 15:49:58 +0000</pubDate>
      <link>https://dev.to/profclems/glab-a-gitlab-cli-tool-1hka</link>
      <guid>https://dev.to/profclems/glab-a-gitlab-cli-tool-1hka</guid>
      <description>&lt;p&gt;I wrote Glab, a simple and elegant GitLab CLI tool written in Go (golang) for creating and managing issues, merge requests, and a lot more... Do give it a try. Your feedback is much appreciated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/profclems/glab"&gt;https://github.com/profclems/glab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitlab.com/profclems/glab"&gt;https://gitlab.com/profclems/glab&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aGJC5ity--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/opzg82163rplv9uhvu07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aGJC5ity--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/opzg82163rplv9uhvu07.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>showdev</category>
      <category>contributorswanted</category>
      <category>githunt</category>
    </item>
  </channel>
</rss>
