1
有沒有辦法使用github API檢查分支是否爲空?檢查分支是否爲空
/repos/:owner/:repo/branches/:branch返回上次提交,但是如何檢查提交是屬於同一個分支還是父分支?
有沒有辦法使用github API檢查分支是否爲空?檢查分支是否爲空
/repos/:owner/:repo/branches/:branch返回上次提交,但是如何檢查提交是屬於同一個分支還是父分支?
如「Find the parent branch of a git branch」所示,git分支沒有「父分支」。相比於其他
一個分支可以是空的,並提前比起其他:
--x--x (branch1)
\
o--o (branch2, branch3)
這裏,branch3
可能比branch2
時被認爲是「空」,並與branch1
2時提前提交。
並且無法知道branch3
是從branch2
還是branch1
創建的。
隨着GitHub的API,你需要compare two commits,它可以是兩個分支名稱:
GET /repos/:owner/:repo/compare/hubot:branchname...octocat:branchname
這將使你的喜歡感興趣的領域:
"status": "behind",
"ahead_by": 1,
"behind_by": 2,
但是這種情況只相對於「另一個分支」而言,沒有簡單的方法來知道「其他分支」是否是其「父」。
比較返回的'total_commits'怎麼樣?同樣的問題? – Johnny
@Johnny是的,同樣的問題。 – VonC