Skip to content

Commit

Permalink
Added, that Git#changed_files updates the repository and working co…
Browse files Browse the repository at this point in the history
…py (`fetch` && `reset --hard`)
  • Loading branch information
karmi committed Mar 2, 2011
1 parent 6c632c7 commit 6903d34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/hide/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(path, sha1, sha2)
end

def changed_files
in_repo('fetch')
update_repo
command = %Q[log --no-merges --pretty="format:%H :|: %s" --stat --name-only --no-color #{@sha1}..#{@sha2}]
output = in_repo(command)
parse output
Expand All @@ -30,5 +30,11 @@ def parse output
end.flatten
end

def update_repo
in_repo('fetch')
# TODO: Make branch optional
in_repo('reset origin/master --hard')
end

end
end
10 changes: 9 additions & 1 deletion test/unit/git_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ class GitTest < Test::Unit::TestCase

should "return updated files" do
command = %Q[log --no-merges --pretty="format:%H :|: %s" --stat --name-only --no-color abc123..def456]
@git.expects(:in_repo).with('fetch').returns('OK')
@git.expects(:update_repo).returns(true)
@git.expects(:in_repo).with(command).returns(GITLOG)

assert_equal 10, @git.changed_files.size
end

should "update the repository" do
@git.expects(:in_repo).with('fetch')
@git.expects(:in_repo).with('reset origin/master --hard')

@git.update_repo
end

end

end
Expand Down

0 comments on commit 6903d34

Please sign in to comment.