怎么在 shell 底下获取 gitlab 的数据?

2015-11-06 14:37:15 +08:00
 oska874

如题,自己用 gitlab 在内网搭建了一个 git server ,在实际使用时,需要获取一些仓库的数据,但是呢我对 web 基本不懂,所以打算直接在服务器上对仓库做处理,提取信息,现在打算先从提取同事对commit 做的comment,就是对提交做的评论,能怎么弄?
或者说 gitlab 有什么线程的接口可以用。

2980 次点击
所在节点    git
6 条回复
hcymk2
2015-11-06 14:54:22 +08:00
oska874
2015-11-06 15:16:15 +08:00
@hcymk2 这个看过了,但是看不懂,看着像是 web 接口,如果要在 shell 下用,怎么弄?
hcymk2
2015-11-06 15:25:51 +08:00
用 curl 直接访问那些接口 ,之后解析 json .
不过 ruby 和 node 好像有现成的工具,
以前只是暂时玩了下这个 https://github.com/drewblessing/gitlab-cli
用 gitlib cli 关键字放狗搜下。
oska874
2015-11-06 16:29:46 +08:00
”用 curl 直接访问那些接口 ,之后解析 json . “ 这个还真不会,没头绪。
我还是先试试 gitlab cli 吧。
ttma1046
2015-11-06 18:37:08 +08:00
不会 curl 的, 快快地写个 jquery, $.ajax()你的 gitlab 的网址加 api 地址会吗?

比如你要看 commits

$.ajax({
url: "http://你的 gitlab 网址 /api/v3/projects/:id/repository/commits", //连接参考楼上 gitlab 的 api doc
method: "GET"
})
.done(function( data ) {
var commitHistory = data;
// 然后就随便玩这个 data object,比如说把你要的 commit message 信息画在网页上阿,等等。。
});

// 这里的 data 应该长这个型
[
{
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
"short_id": "ed899a2f4b5",
"title": "Replace sanitize with escape once",
"author_name": "Dmitriy Zaporozhets",
"author_email": "dzaporozhets@sphereconsultinginc.com",
"created_at": "2012-09-20T11:50:22+03:00",
"message": "Replace sanitize with escape once"
},
{
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
"short_id": "6104942438c",
"title": "Sanitize for network graph",
"author_name": "randx",
"author_email": "dmitriy.zaporozhets@gmail.com",
"created_at": "2012-09-20T09:06:12+03:00",
"message": "Sanitize for network graph"
}
]
oska874
2015-11-06 20:32:45 +08:00
@ttma1046 curl 都不熟,更何况 js 了,我先慢慢消化一下。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/234159

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX