楽しいプロジェクトとして、私はgit-cmd.exeプロセスを通していくつかのコマンドをC#経由で実行しようとしています。ウィンドウなしのgit bashプロセスを開く
私は複数のコマンドを実行するには、このコードを持っている:
var info = new ProcessStartInfo(@"C:\Program Files\Git\git-cmd.exe");
info.RedirectStandardInput = true;
info.UseShellExecute = false;
var gitProcess = new Process { StartInfo = info };
gitProcess.Start();
using (StreamWriter sw = gitProcess.StandardInput)
{
// commands here
}
gitProcess.WaitForExit();
これは細かい動作しますが、私は、次のコマンドを実行しようとすると、私はいくつかのメッセージを取得しています。
コマンド(https://stackoverflow.com/a/33656490/1671161):
curl -X POST -v -u username:password https://api.bitbucket.org/2.0/repositories/TeamName/reponame -H "Content-Type: application/json" -d '{"scm": "git", "is_private": true, "fork-policy": "no_public_forks", "has_issues": true}'
メッセージ:
Note: Unnecessary use of -X or --request, POST is already inferred.
* timeout on name lookup is not supported
* Trying 2401:1d80:1010::153...
* Connected to api.bitbucket.org (2401:1d80:1010::153) port 443 (#0)
#more messages, seems OK to me so far, but then this:
Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
* HTTP 1.0, assume close after body
< HTTP/2 400
< server: nginx/1.6.2
< vary: Authorization, Cookie
< content-type: text/plain
< strict-transport-security: max-age=31536000
< date: Wed, 10 Aug 2016 17:34:57 GMT
< x-served-by: app-112
< x-static-version: 89c5b48218a9
< etag: "825644f747baab2c00e420dbbc39e4b3"
< x-render-time: 0.0194010734558
< x-accepted-oauth-scopes: repository:admin
< x-version: 89c5b48218a9
< x-request-count: 459
< x-frame-options: SAMEORIGIN
< content-length: 11
<
Bad Request* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: git,/
* timeout on name lookup is not supported
* getaddrinfo(3) failed for git,:80
* Couldn't resolve host 'git,'
* Closing connection 1
BitBuckets APIドキュメントを見ると、入力文書が無効だった場合は400リターン状態」を意味し、または発信者が不足している場合ターゲットアカウントの下にリポジトリを作成する特権残念ながら、私はgit-cmd.exeでコマンドを実行するための正しいフォーマットを見つけることができませんでした。
コマンドはGitのバッシュで正常に動作するので、私はGitのbashのプロセスを実行しようとした:
var gitbashinfo = new ProcessStartInfo(@"C:\Program Files\Git\git-bash.exe");
gitbashinfo.RedirectStandardInput = true;
gitbashinfo.UseShellExecute = false;
var gitbashProcess = new Process { StartInfo = gitbashinfo };
gitbashProcess.Start();
using (StreamWriter sw = gitbashProcess.StandardInput)
{
// The command
}
gitbashProcess.WaitForExit();
しかし、これはGitのBashのウィンドウを開き、私のコマンドを実行しません。 Git-cmd.exeプロセスで行ったのとまったく同じことをプログラムが期待していました。したがって、新しいウィンドウを開くのではなく、既に開いているウィンドウ内のすべてのコマンドを実行し、出力も表示します。
私の質問は、どのように私のgit-cmd.exeプロセスで正常に実行するためにCURLコマンドを実行できますか?または、私のプログラムウィンドウ内でgit-bash.exeプロセスをどのように実行すればよいですか?
すでにこれまでに試したことがありますが、まだ新しいウィンドウが作成されています。 – FJPoort