如何从终端使用 Gitlab 的问题?

How to use issues of Gitlab from terminal?

我知道您可以通过安装 ghi 在命令行上使用 Github 问题。

但是,有没有什么方法可以使用类似的工具来解决 Gitlab 上的 listing/adding/removing/editing 个存储库问题?

您有一个与 Itxaka/pyapi-gitlab

相似的包装器(在 python,而不是 ruby)
git = gitlab.Gitlab(host=host)
git.login(user=user, password=password)
git.getall(git.getprojects)

git.getissues(page=1, per_page=40)

在 ruby 中是 NARKOZ/gitlab:

# set an API endpoint
Gitlab.endpoint = 'http://example.net/api/v3'
# => "http://example.net/api/v3"

# set a user private token
Gitlab.private_token = 'qEsq1pt6HJPaNciie3MG'
# => "qEsq1pt6HJPaNciie3MG"

# configure a proxy server
Gitlab.http_proxy('proxyhost', 8888)
# proxy server w/ basic auth
Gitlab.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')

# list projects
Gitlab.projects(per_page: 5)

可以fetch issues.

回答我自己的问题。

一开始我以为ghi也可以在Gitlab上使用,后来发现ghi有以下问题,其中ghi的所有者说目前不支持Gitlab。

以防万一您花时间搜索 ghi 和 Gitlab 使用之间的兼容性。

I'm not opposed to the feature (if introduced simply), but G.H.I. is definitely built around GitHub Issues. I'm also not a user of GitLab, so the enhancement would have to come from someone else.

https://github.com/stephencelis/ghi/issues/135

好像有人写了gitlab的CLI工具API:

https://python-gitlab.readthedocs.io/en/stable/cli.html

pip3 install --user python-gitlab
$EDITOR ~/.python-gitlab.cfg 

gitlab 主站点的示例配置,但您也可以添加自己的本地实例:

[global]
default = gitlab
ssl_verify = true
timeout = 5

[gitlab]
url = https://gitlab.com
private_token = <insert API token here>
api_version = 4

确保你的路径包含 /home/<username>/.local/bin/

然后从你的 gitlab 仓库中:

gitlab issue list

我不确定它是否像 ghi 一样完整,但看起来它支持大量的 API。

这个答案并没有解决你的全部问题,只是一小部分。

要以编程方式创建问题,您可以使用 New issue via URL 功能。

它允许您通过带有参数的 URL 创建带有标题和描述(如果需要使用模板)的问题。

URL 看起来像这样:

https://gitlab.instance.url/group_name/project_name/issues/new?issue[title]=Your%20issue%20title&issue[description]=Issue%20description

我已经将其包装在绑定到 CTRLALTT 的 AHK 快捷方式中。为了完整起见,我加入了 URLEncode 函数。

;; Create issue on Gitlab tasks list with selected text as issue title
^!t::
ClipSaved := ClipboardAll
Sleep, 300
Send ^c
title := URLEncode(clipboard)
mainURL := "https://gitlab.instance.com/gitlab/group_name/project/issues/new?issue[title]="
fullURL := mainURL title
Run, %fullURL%
Clipboard := ClipSaved
return

UrlEncode( String )
{
    OldFormat := A_FormatInteger
    SetFormat, Integer, H

    Loop, Parse, String
    {
        if A_LoopField is alnum
        {
            Out .= A_LoopField
            continue
        }
        Hex := SubStr( Asc( A_LoopField ), 3 )
        Out .= "%" . ( StrLen( Hex ) = 1 ? "0" . Hex : Hex )
    }

    SetFormat, Integer, %OldFormat%

    return Out
}

GLab 似乎是个不错的选择。

GLab is an open source Gitlab Cli tool written in Go (golang) to help work seamlessly with Gitlab from the command line. Work with issues, merge requests, watch running pipelines directly from your CLI among other features.

https://github.com/profclems/glab