Permalink
Browse files

Add support for using a different remote repository

  • Loading branch information...
Ryan Burrows
Ryan Burrows committed Apr 8, 2010
1 parent 8bfb959 commit 85e76e50907914d463d01a38ba7ace5450cde21c
View
@@ -0,0 +1,12 @@
=== 0.0.2 / 2010-04-08
* 1 minor enhancement:
* Support for specifying a different remote repository
=== 0.0.1 / 2010-04-08
* 1 major enhancement:
* Initial release
@@ -32,3 +32,17 @@ Feature: Reviewr gets user information
Given I enter "asdfasdf" for my email password
When I run a reviewr command that requires email
Then the email password should be set to "asdfasdf"
Scenario: Reviewr asks for the remote repo name
When I run a reviewr command that requires email
Then I should see "Remote repository (default origin): "
Scenario: Reviewr default the remote repository to origin
Given I use the default remote repository
When I run a reviewr command that requires email
Then the remote repository should be set to "origin"
Scenario: Reviewr takes the remote repo I enter
Given I enter "remote_name" for the remote repository
When I run a reviewr command that requires email
Then the remote repository should be set to "remote_name"
@@ -1,7 +1,7 @@
Given /^assuming I enter valid email account information$/ do
Given 'I enter "coder@site.com" for my email'
Given 'I enter "asdfasdf" for my email password'
Given 'I enter "site.com" for my email server'
Given 'I use the default remote repository'
end
Given /^I use the default email$/ do
@@ -16,12 +16,12 @@
input.password = pass
end
Given /^I use the default email server$/ do
Given "I enter \"\n\" for my email server"
Given /^I use the default remote repository$/ do
Given "I enter \"\n\" for the remote repository"
end
Given /^I enter "([^\"]*)" for my email server$/ do |server|
input.email_server = server
Given /^I enter "([^\"]*)" for the remote repository$/ do |repo|
input.remote_repo = repo
end
When /^I run a reviewr command that requires email$/ do
@@ -44,6 +44,10 @@
project.email_server.should == server
end
Then /^the remote repository should be set to "([^\"]*)"$/ do |repo|
project.remote_repo.should == repo
end
def project
reviewr.project
end
@@ -12,8 +12,8 @@ def password=(password)
@messages[1] = password
end
def email_server=(server)
@messages[2] = server
def remote_repo=(repo)
@messages[2] = repo
end
def gets
View
@@ -33,6 +33,10 @@ def prompt_for_user(input = STDIN, output = STDOUT)
no_echo(input) do
project.email_password = input.gets.chomp
end
output.print("Remote repository (default origin): ")
repo = input.gets.chomp
project.remote_repo = repo unless repo.empty?
end
private
View
@@ -10,6 +10,12 @@ def instance=(instance)
end
end
attr_writer :remote_repo
def remote_repo
@remote_repo ||= "origin"
end
def last_commit
execute('git show --pretty=format:"%H" HEAD').split("\n")[0]
end
@@ -32,7 +38,7 @@ def push_branch(branch_name)
end
def origin_location
r = execute("git remote show origin")
r = execute("git remote show #{remote_repo}")
r && r.match(/URL: (.+)$/)[1]
end
View
@@ -5,9 +5,11 @@ class Project
extend Forwardable
attr_reader :to, :git, :email_server
attr_accessor :user_email, :email_password
attr_accessor :email_password
attr_writer :user_email
def_delegators :git, :push_branch, :origin_location
def_delegators :git, :push_branch, :origin_location, :remote_repo,
:remote_repo=
def initialize(to, git = Git.instance)
@to, @git = to, git
View
@@ -1,3 +1,3 @@
module Reviewr
VERSION = "0.0.1"
VERSION = "0.0.2"
end
@@ -94,6 +94,24 @@ def new_main(args)
input.stub(:gets).and_return("email@s.com", "asdf")
main.prompt_for_user(input, output)
end
it "Asks for the remote repository name" do
output.should_receive(:print).
with("Remote repository (default origin): ")
main.prompt_for_user(input, output)
end
it "Sets the entered remote repository into the project" do
main.project.should_receive(:remote_repo=).with("remote_name")
input.stub(:gets).and_return("remote_name\n")
main.prompt_for_user(input, output)
end
it "Uses the default remote repository if an empty string is entered" do
main.project.should_not_receive(:remote_repo=)
input.stub(:gets).and_return("\n")
main.prompt_for_user(input, output)
end
end
end
end
View
@@ -46,7 +46,8 @@ module Reviewr
end
describe "#origin_location" do
it "runs show on the remote origin" do
it "runs show on the remote remote repo" do
git.remote_repo = "origin"
git.should_receive(:execute).with('git remote show origin')
git.origin_location
end

0 comments on commit 85e76e5

Please sign in to comment.