V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
oska874
V2EX  ›  git

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

  •  1
     
  •   oska874 · 2015-11-06 14:37:15 +08:00 · 2975 次点击
    这是一个创建于 3105 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    6 条回复    2015-11-06 20:32:45 +08:00
    hcymk2
        1
    hcymk2  
       2015-11-06 14:54:22 +08:00
    oska874
        2
    oska874  
    OP
       2015-11-06 15:16:15 +08:00
    @hcymk2 这个看过了,但是看不懂,看着像是 web 接口,如果要在 shell 下用,怎么弄?
    hcymk2
        3
    hcymk2  
       2015-11-06 15:25:51 +08:00
    用 curl 直接访问那些接口 ,之后解析 json .
    不过 ruby 和 node 好像有现成的工具,
    以前只是暂时玩了下这个 https://github.com/drewblessing/gitlab-cli
    用 gitlib cli 关键字放狗搜下。
    oska874
        4
    oska874  
    OP
       2015-11-06 16:29:46 +08:00
    ”用 curl 直接访问那些接口 ,之后解析 json . “ 这个还真不会,没头绪。
    我还是先试试 gitlab cli 吧。
    ttma1046
        5
    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": "[email protected]",
    "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": "[email protected]",
    "created_at": "2012-09-20T09:06:12+03:00",
    "message": "Sanitize for network graph"
    }
    ]
    oska874
        6
    oska874  
    OP
       2015-11-06 20:32:45 +08:00
    @ttma1046 curl 都不熟,更何况 js 了,我先慢慢消化一下。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2627 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 16:08 · PVG 00:08 · LAX 09:08 · JFK 12:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.