Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #527 from liggitt/git_pull
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Dec 19, 2013
2 parents c89ca7f + 4952331 commit fe71cce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions features/core_feature.rb
Expand Up @@ -114,13 +114,19 @@
Dir.chdir @app.name
end
let(:git_config){ `git config --list` }
let(:git_remotes){ `git remote -v` }

it "will set Git config values" do
git_config.should match "rhc.app-id=#{app.id}"
git_config.should match "rhc.app-name=#{app.name}"
git_config.should match "rhc.domain-name=#{app.domain_name}"
end

it "will set remote branches correctly" do
git_remotes.should match "origin"
git_remotes.should_not match "upstream"
end

it "will infer the current app from the git repository" do
r = rhc 'show-app'
r.stdout.should match app.name
Expand Down
9 changes: 9 additions & 0 deletions lib/rhc/git_helpers.rb
Expand Up @@ -41,13 +41,22 @@ def git_clone_application(app)
git_config_set "rhc.app-id", app.id
git_config_set "rhc.app-name", app.name
git_config_set "rhc.domain-name", app.domain_id

git_remote_add("upstream", app.initial_git_url) if app.initial_git_url.present?
end

git_clone_deploy_hooks(repo_dir)

dir
end

def git_remote_add(remote_name, remote_url)
cmd = "#{git_cmd} remote add upstream \"#{remote_url}\""
debug "Running #{cmd} 2>&1"
output = %x[#{cmd} 2>&1]
raise RHC::GitException, "Error while adding upstream remote - #{output}" unless output.empty?
end

# :nocov: These all call external binaries so test them in cucumber
def git_config_get(key)
return nil unless has_git?
Expand Down
13 changes: 13 additions & 0 deletions spec/rhc/commands/git_clone_spec.rb
Expand Up @@ -53,6 +53,19 @@

it { expect { run }.to exit_with_code(0) }
it { run_output.should match("Cloned") }

context 'when app has an initial git url' do
before do
@app2 = @domain.add_application("app2", "mock_unique_standalone_cart", nil, "default", "git://test")
@instance.stub(:git_remote_add) do |remote_name, remote_url|
say "Added remote #{remote_name} pointing to #{remote_url}"
true
end
end
let(:arguments) { ['git-clone', 'app2'] }
it { run_output.should match("Added remote upstream pointing to git://test") }
end

end

context "testing git_clone_deploy_hooks" do
Expand Down

0 comments on commit fe71cce

Please sign in to comment.