2017-10-09 60 views

回答

1

基於@MarkAdelsberger答案,這裏是一個快速的python腳本,它返回github上的git存儲庫日誌。它期望兩個參數,用戶名repo名稱

#!/usr/bin/python 
# github_log.py 
import urllib2, json, sys 

json_str = urllib2.urlopen("https://api.github.com/repos/{}/{}/commits" 
     .format(sys.argv[1], sys.argv[2])).read() 
commits = json.loads(json_str) 

for c in commits: 
    print c['sha'][0:8],c['commit']['message'].split('\n')[0] 

./github_log.py microsoft vscode 

回報:

a4ae8375 fix decorations service test 
45a71083 :lipstick: 
9613370d update title area faster when opening a new group 
42e1d19a composite bar polish css classes 
8f4e125a Fix compilation errors 
3170a7f5 Do not overload getConfiguration for sending it to extension host. Use getConfigurationData 
f704a6c7 composite part: move pin/unpin/mode to compositePart 
5276a4fc deco - proper explorer update on config change 
2

一般來說,你不能。但取決於究竟是你想要什麼,也許你可以做出某種工作。

git命令行提供與遙控器的非常有限的交互。您通常只需要fetch,pushpull。 (有一些「不太常見」的遠程交互,但沒有一個像你所問的那樣)。但幾乎所有事情都是通過設計在本地完成的。

您所談論的-C場景正在利用非常特殊的情況。你實際上並沒有將你的裸回購作爲一個遙控器進行交互;你告訴Git像本地回購一樣訪問它。實際上,您可能只是cd /media/git-repos/project-git,然後正常運行git log;因爲它確實是本地可訪問的。

但是你不能cd到github回購;你的訪問是通過git的遠程協議,或者通過github提供的API。 (類似的情況將適用於任何遠程託管服務。)在github的情況下,具體來說,這些都是web API。

因此,如果您知道提供所需結果的網絡API請求,則可以通過curl提供該請求。這是關於你能做的最好的事情。您可以從commits API調用中獲得所需信息,這裏記錄:https://developer.github.com/v3/repos/commits/

相關問題