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

时间:2015-08-07 05:55:55

标签: git gitlab

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

但是,有没有办法在 Gitlab 上使用类似工具列出/添加/删除/编辑存储库问题?

5 个答案:

答案 0 :(得分:3)

你有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)

在红宝石中,那将是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

答案 1 :(得分:2)

GLab似乎是一个不错的选择。

GLab是用Go(golang)编写的开源Gitlab Cli工具,可帮助从命令行与Gitlab无缝协作。在其他功能中,可以直接从CLI处理问题,合并请求,监视正在运行的管道。

https://github.com/profclems/glab

答案 2 :(得分:0)

回答我自己的问题。

起初我认为ghi也可以在Gitlab上找到,但之后我发现了ghi的下面问题,其中ghi的所有者说目前它不支持Gitlab。

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

  

我不反对这个特征(如果简单介绍的话),但是G.H.I.绝对是围绕GitHub问题构建的。我也不是GitLab的用户,因此增强功能必须来自其他人。

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

答案 3 :(得分:0)

似乎有人为gitlab的API编写了CLI工具:

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。

答案 4 :(得分:0)

这个答案并不能解决您的全部问题,只是一小部分。

要以编程方式创建问题,可以使用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

我将其包装在绑定到 CTRL ALT T 的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
}