lib/braid/command.rb in braid-0.7.1 vs lib/braid/command.rb in braid-1.0.0
- old
+ new
@@ -29,11 +29,11 @@
def msg(str)
self.class.msg(str)
end
def config
- @config ||= load_and_migrate_config
+ @config ||= Config.new
end
def verbose?
Braid.verbose
end
@@ -59,10 +59,12 @@
def bail_on_local_changes!
git.ensure_clean!
end
def with_reset_on_error
+ bail_on_local_changes!
+
work_head = git.head
begin
yield
rescue => error
@@ -70,67 +72,32 @@
git.reset_hard(work_head)
raise error
end
end
- def load_and_migrate_config
- config = Config.new
- unless config.valid?
- msg "Configuration is outdated. Migrating."
- bail_on_local_changes!
- config.migrate!
- git.commit("Upgrade .braids", "-- .braids")
- end
- config
- end
-
def add_config_file
git.add(CONFIG_FILE)
end
def display_revision(mirror, revision = nil)
revision ||= mirror.revision
- mirror.type == "svn" ? "r#{revision}" : "'#{revision[0, 7]}'"
+ "'#{revision[0, 7]}'"
end
def validate_new_revision(mirror, new_revision)
- unless new_revision
- unless mirror.type == "svn"
- return git.rev_parse(mirror.remote)
- else
- return svn.head_revision(mirror.url)
- end
- end
+ return git.rev_parse(mirror.remote) unless new_revision
- unless mirror.type == "svn"
- new_revision = git.rev_parse(new_revision)
- else
- new_revision = svn.clean_revision(new_revision)
- end
+ new_revision = git.rev_parse(new_revision)
old_revision = mirror.revision
if new_revision == old_revision
- raise InvalidRevision, "mirror is already at requested revision"
+ raise InvalidRevision, 'mirror is already at requested revision'
end
- if mirror.type == "svn"
- if old_revision && new_revision < old_revision
- raise InvalidRevision, "local revision is higher than request revision"
- end
-
- if svn.head_revision(mirror.url) < new_revision
- raise InvalidRevision, "requested revision is higher than remote revision"
- end
- end
-
new_revision
end
- def determine_target_revision(mirror, new_revision)
- unless mirror.type == "svn"
- git.rev_parse(new_revision)
- else
- git_svn.commit_hash(mirror.remote, new_revision)
- end
+ def determine_target_revision(new_revision)
+ git.rev_parse(new_revision)
end
end
end