通过分支名称使用git api获取git提交 [英] Get git commits by branch name\id with git api

查看:140
本文介绍了通过分支名称使用git api获取git提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发自动化服务以使用Git中心存储库。我的问题在我身边 - 我无法找到一种方法来通过它的hash \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

我的代码是一个自动化的工具,可以让代码审查。所以我添加了一个功能来忽略我的评论过程中的特定分支(例如测试分支或类似的东西)。所以在我的服务中,我将分支标记为忽略。一旦我从git hub api获得提交 - 那里没有关于当前提交属于哪个分支的信息。

我开始考虑我的整体github思路是错误的 - 因为commit-branch链接是非常明显的事情,所以应该有一些东西让API开发人员忽略 GetCommits 方法



所以我的问题是 - 有没有办法找出哪个分支提交(使用v3 api json结果)属于github api(v3 - GET / repos /:owner /:repo / commits /:sha)。



Thanks

解决方案

如果您只想检查您的提交是否在分支上test123,do:

https://api.github.com/repos/golang/go/compare/test123...001a75a74c4a27901b0b536efe1be581612c52a9



并检查状态。

如果它'相同'或'后面',那么提交i作为分支的一部分。如果不一样,那不是。


I am working on automated service to work with Git hub repositories. And I am having problem on my side - I can't find a way to get all commit in particular branch by its hash\name.

My code is an automated tool to make code reviewes. So I've added a feature to ignore particular branch in my review process (ex. a testing branch or something like that). So in my service I am marking branch as ignored. Once I get commits from git hub api - there is no information there about which branch is current commit belongs to.

I started thinking that my overall github idea is wrong - since commit-branch link is pretty obvious thing so there should be something that made the API developers to ignore that in the GetCommits method

So my question is - Is there a way to find out which branch commit (using v3 api json result) belongs to in github api (v3 - GET /repos/:owner/:repo/commits/:sha).

Thanks

解决方案

If you just want to check if your commit is for example on branch test123, do:

https://api.github.com/repos/golang/go/compare/test123...001a75a74c4a27901b0b536efe1be581612c52a9

and check the status.

If it's 'identical' or 'behind', then the commit is part of the branch. If it is different, it's not.

这篇关于通过分支名称使用git api获取git提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆