无论如何,以编程方式获取私人github回购的zipball? [英] Is there anyway to programmatically fetch a zipball of private github repo?

查看:89
本文介绍了无论如何,以编程方式获取私人github回购的zipball?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有必要获取私人回购的zipball。对于公众来说,通过GitHub API或手动( https://github.com/user/repo/zipball/master )非常简单。但是私人回购呢?不是很明显,即使有oAuth令牌也要怎么做。

解决方案

新选择



因为给定的接受的答案不再有效,所以我想我会解释我是如何通过github API中的新变化来实现的。



新的下载API链接



首先,我找到有关下载档案的信息:
< a href =https://developer.github.com/v3/repos/contents/#get-archive-link =nofollow noreferrer> https://developer.github.com/v3/repos/contents/ #get-archive-link

公开回购



如果这是一个公共回购,然后它是非常容易的...你可以这样做:

  curl -L https://api.github .com / repos / pengwynn / octokit / tarball> octokit.tar.gz 

私人回购



如果它是私人回购,您需要创建一个oAuth令牌,方法是转到您的设置,然后选择开发者设置/个人访问令牌
我创建了一个个人令牌。

然后使用下面的页面上的说明,我发现如何获得您有权限的私人回购:
https://developer.github.com/v3/#authentication



完整代码

  curl -H授权: token ab499f3b ...\ 
-L ​​https://api.github.com/repos/godzilla/my_priv_repo/tarball> wut.tar.gz

请务必替换 ab499f3b ... 与您的实际令牌。


We got a necessity to fetch a zipball of a private repo. For public ones it's pretty easy either through GitHub API or manually (https://github.com/user/repo/zipball/master). But what about private repos? Not exactly obvious how to do it even having oAuth token.

解决方案

New Alternative

Because the given accepted answer does not work anymore, I thought I would explain how I was able to do it with the new changes in the github API.

The new Download Api Link

First, I found information about downloading the archive here: https://developer.github.com/v3/repos/contents/#get-archive-link

Public Repo

If it's a public repo then it is very easy... you can do:

curl -L https://api.github.com/repos/pengwynn/octokit/tarball > octokit.tar.gz

Private Repo

If it's it is a private repo, you need to create an oAuth token by going to your settings and then selecting "Developer settings" / "Personal access tokens". I created a personal token.

Then using the instructions on the following page I found out how to get private repo that you have permission to: https://developer.github.com/v3/#authentication

Full Code

curl -H "Authorization: token ab499f3b..." \
-L https://api.github.com/repos/godzilla/my_priv_repo/tarball > wut.tar.gz

Be sure to replace ab499f3b... with your actual token.

这篇关于无论如何,以编程方式获取私人github回购的zipball?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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