diff --git a/features/sync_gemfile.feature b/features/sync_gemfile.feature index 1b1ed8a..d5f91ce 100644 --- a/features/sync_gemfile.feature +++ b/features/sync_gemfile.feature @@ -51,4 +51,19 @@ Feature: sync a Gemfile between two repositories gem "postgresql" >>>>>>> .trout/upstream """ - + When I write to "Gemfile" with: + """ + source "http://rubygems.org" + gem "rails" + gem "mysql" + gem "redcloth" + """ + When I run "trout update Gemfile" + And I run "cat Gemfile" + Then the output should contain: + """ + source "http://rubygems.org" + gem "rails" + gem "mysql" + gem "redcloth" + """ diff --git a/lib/trout/managed_file.rb b/lib/trout/managed_file.rb index b3d8b26..6cd310f 100644 --- a/lib/trout/managed_file.rb +++ b/lib/trout/managed_file.rb @@ -19,7 +19,10 @@ def copy_from(git_url) def update checkout(previous_git_url) - merge_to_destination + unless up_to_date? + merge_to_destination + write_url_and_version + end ensure cleanup end @@ -76,7 +79,7 @@ def write_url_and_version end def checked_out_version - git_command("rev-parse HEAD") + git_command("rev-parse master") end def checkout_last_version @@ -95,6 +98,10 @@ def previous_git_version version_list.version_for(filename) end + def up_to_date? + previous_git_version == checked_out_version + end + def version_list @version_list ||= VersionList.new(working('versions')) end