Permalink
Browse files

override your fork

  • Loading branch information...
1 parent edf49d3 commit 66b3f88d4d573c14afdd8853e61f2a84221a04c1 @holman committed May 13, 2010
Showing with 42 additions and 10 deletions.
  1. +22 −8 lib/tissues/sync.rb
  2. +1 −0 test/test_helper.rb
  3. +17 −0 test/test_sync.rb
  4. +2 −2 tissues.gemspec
View
@@ -18,8 +18,8 @@ def go!
local_todos = area.todos
sync_back_to_github = []
- repository = Repository.find(:name => origin_path.split('/').last,
- :user => origin_path.split('/').first)
+ repository = Repository.find(:name => github_repo.split('/').last,
+ :user => github_repo.split('/').first)
all_issues = repository.all_issues
if all_issues.size > 0
@@ -76,18 +76,32 @@ def go!
def area
return @area if defined? @area
- @area = Things::Area.find(origin_path) ||
- Things::Area.create(:name => origin_path)
+ @area = Things::Area.find(github_repo) ||
+ Things::Area.create(:name => github_repo)
end
- def origin_path
- return @origin_path if defined? @origin_path
- @origin_path = `git remote -v | grep fetch`.
+ def github_repo
+ different_remote? ? local_remote_path : git_remote_path
+ end
+
+ def different_remote?
+ File.exist?('.tissues')
+ end
+
+ def git_remote_path
+ cmd('git remote -v | grep fetch').
split(':').
last.
split('.git ').
first
end
-
+
+ def local_remote_path
+ File.new('.tissues').readline.chomp
+ end
+
+ def cmd(command)
+ `#{command}`
+ end
end
end
View
@@ -1,6 +1,7 @@
require 'rubygems'
require 'test/unit'
require 'spec/mini'
+require 'mocha'
require 'tissues'
View
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/test_helper'
+
+context "syncing" do
+ test "github_repo is the git remote" do
+ Tissues::Sync.stubs(:different_remote?).returns(false)
+ Tissues::Sync.stubs(:cmd).with('git remote -v | grep fetch').returns('holman/dotfiles')
+ assert_equal 'holman/dotfiles', Tissues::Sync.github_repo
+ end
+
+ test "github_repo is overriden" do
+ Tissues::Sync.stubs(:different_remote?).returns(true)
+ path = "zachholman/dotfiles\n"
+ path.stubs(:readline).returns(path)
+ File.stubs(:new).returns(path)
+ assert_equal 'zachholman/dotfiles', Tissues::Sync.github_repo
+ end
+end
View
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
## List your development dependencies here. Development dependencies are
## those that are only needed during development
- # s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"])
+ s.add_development_dependency('mocha', [">= 0.9.8"])
## Leave this section as-is. It will be automatically generated from the
## contents of your Git repository via the gemspec task. DO NOT REMOVE
@@ -68,5 +68,5 @@ Gem::Specification.new do |s|
## Test files will be grabbed from the file list. Make sure the path glob
## matches what you actually use.
- # s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
end

0 comments on commit 66b3f88

Please sign in to comment.