12

Rails アプリケーションGemfileで Github プライベート リポジトリ参照を使用するために、さまざまなアプローチを試しました。

1) Gemfile:
gem 'my_gem', :git => "https://#{github_user}:#{github_pw}@github.com/me/my_gem.git"

「git push heroku」の結果:

Fetching https://user:pw@github.com/me/my_gem.git
error: The requested URL returned error: 401 while accessing https://user:pw@github.com/me/my_gem.git/info/refs
Git error: command `git clone 'https://user:pw@github.com/me/my_gem.git' "/tmp/build_2wxmqutch8gy7/vendor/bundle/jruby/1.9/cache/bundler/git/my_gem-929bddeee3dd4a564c2689e189190073df01431e" --bare --no-hardlinks` in directory /tmp/build_2wxmqutch8gy7 has failed.
Dependencies installed

次に、この記事https://help.github.com/articles/creating-an-oauth-token-for-command-line-useを見つけて、OAuth トークンを作成しました。

2) Gemfile:
gem 'my_gem', :git => "https://#{github_oauth_token}@github.com/me/my_gem.git"

「git push heroku」の結果:

Fetching https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
Password:

Heroku が停止し、パスワードを求めるプロンプトが表示されます。

私のローカルマシンでは両方:

git clone https://user:pw@github.com/me/my_gem.git

git clone https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git

完璧に動作します!

ローカル:

# git --version
git version 1.7.9.5

ヘロク:

# heroku run git --version
git version 1.7.0
4

2 に答える 2

6

Heroku は古いバージョンの Git を実行しますが、残念ながら URL の認証部分を完全にはサポートしていません。

GitHub が提供するダミーのパスワードを追加することで、これを回避できます。したがって、使用する代わりに:

https://#{github_oauth_token}@github.com/me/my_gem.git

使用する:

https://#{github_oauth_token}:x-oauth-basic@github.com/me/my_gem.git
于 2013-01-24T00:59:30.733 に答える
2

Heroku の git (バージョン 1.7) は、Github のリポジトリのユーザー名として電子メールを使用することをサポートしていません。

Github ユーザー名を使用する必要があります。

また、Heroku の git は oauth トークンの使用をサポートしていません。

Heroku がすぐに git をアップグレードしてくれることを願っています。

于 2012-11-01T08:22:38.767 に答える