2017-03-25 6 views
0

私はGitHubリポジトリ内のコンテンツ(ファイルとフォルダ)を含むディレクトリをAPI経由でダウンロードする方法を考えています。記事のいくつかはOctokit.Net言及ので、私はこれをダウンロードして、次の行を書いた:C#GitHub(Octokit.Net)のサブディレクトリとファイルを含む完全なディレクトリ構造をダウンロードしてください。

var github = new GitHubClient(new ProductHeaderValue("PROJECT"), new InMemoryCredentialStore(new Credentials("xxxtokenxxx"))); 

var repositories = github.Repository.GetAllForCurrent().Result; 

var repository = repositories.Single(x => x.Name == "MyRepo"); 

さて私は、リポジトリを取得し、それが動作しますが、私はどこここから行くことがわかりませんか?

すべてのファイルを含むFolder1(下図)と構造内のファイルを含むFolder2をローカルのハードディスクにダウンロードするにはどうすればよいですか?

https://github.com/PROJECT/MyRepo/tree/2016-1/Folder1/Folder2

誰もが正しい方向に私を助けることができますか?あなたの助けが大変ありがとうございます。ありがとう

答えて

-1

GITはプロセス経由で実行してみませんか? Like

Process proc = new Process(); 
proc.StartInfo.FileName = @"git"; 
proc.StartInfo.Arguments = string.Format(@"clone ""{0}"" ""{1}""", repository_address, target_directory); 
proc.StartInfo.UseShellExecute = false; 
proc.StartInfo.CreateNoWindow = true; 
proc.Start(); 
proc.WaitForInputIdle(); 

私はこれがうまくいくと思います。しかし、私は間違っているかもしれません。 :)

EDIT:設定ユーザーの資格情報を持つ

// Create process 
Process proc = new Process(); 
proc.StartInfo.FileName = @"*your_git_location*\\git-bash.exe"; 
proc.StartInfo.RedirectStandardInput = true; 
proc.StartInfo.UseShellExecute = false; 
proc.StartInfo.CreateNoWindow = true; 
proc.Start(); 
// Wait for it to run 
proc.WaitForInputIdle(); 
// Set up user name 
proc.StandardInput.WriteLine("git config user.name ""your_user_name"""); 
proc.WaitForInputIdle(); 
// Set up user email 
proc.StandardInput.WriteLine("git config user.email ""your_user_email"""); 
proc.WaitForInputIdle(); 
// Request clone of repository 
proc.StandardInput.WriteLine(string.Format(@"git clone ""{0}"" ""{1}""", repository_address, target_directory);); 
proc.WaitForInputIdle(); 
// Now git should ask for your password 
proc.StandardInput.WriteLine("your_password"); 
proc.WaitForInputIdle(); 
// Now clone should be complete 
proc.Dispose(); 

このSHOULD仕事に、私はそれをテストしていないし、また、いくつかの構文エラーがあるかもしれませんが、私はあなたがそれらを把握と信じています。 GITの認証に関しては、資格ヘルパー thoと呼ばれる機能を使用して証明書を保存することができます。これを設定する方法はわかりません。私はそこから研究してみてください、この質問は良いスタートだと思う:

Is there a way to skip password typing when using https:// on GitHub?

+0

ありがとうございましたしかし、私はこのアプローチを使用して(情報をログイン)私の資格情報をどこに置いたかわかりません。 – NorthRebel

+0

そうです。右。私はそれを考えなかった。私は可能な解決策で新しい答えを書くつもりです。コメントには長すぎます。 :) – RhodryCZ

+0

これは、コマンドライン注入を提供します。あなたの入力が信頼できない攻撃者によって提出された場合、私は彼らが楽しいと思うでしょう。 – Mitch

関連する問題