Skip to content

Commit

Permalink
override your fork
Browse files Browse the repository at this point in the history
  • Loading branch information
holman committed May 13, 2010
1 parent edf49d3 commit 66b3f88
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
30 changes: 22 additions & 8 deletions lib/tissues/sync.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions test/test_helper.rb
@@ -1,6 +1,7 @@
require 'rubygems'
require 'test/unit'
require 'spec/mini'
require 'mocha'

require 'tissues'

Expand Down
17 changes: 17 additions & 0 deletions test/test_sync.rb
@@ -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
4 changes: 2 additions & 2 deletions tissues.gemspec
Expand Up @@ -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
Expand All @@ -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.