lib/braid/command.rb in braid-1.0.17 vs lib/braid/command.rb in braid-1.0.18

- old
+ new

@@ -43,11 +43,17 @@ end private def setup_remote(mirror) - Command.run(:setup, mirror.path) + existing_force = Braid.force + begin + Braid.force = true + Command.run(:setup, mirror.path) + ensure + Braid.force = existing_force + end end def clear_remote(mirror, options) git.remote_rm(mirror.remote) unless options['keep'] end @@ -86,20 +92,35 @@ def display_revision(mirror, revision = nil) revision ||= mirror.revision "'#{revision[0, 7]}'" end - def validate_new_revision(mirror, new_revision) - return git.rev_parse("#{mirror.remote}/#{mirror.branch}") unless new_revision + def determine_repository_revision(mirror) + if mirror.tag + if use_local_cache? + Dir.chdir git_cache.path(mirror.url) do + git.rev_parse(mirror.local_ref) + end + else + raise BraidError, 'unable to retrieve tag version when cache disabled.' + end + else + git.rev_parse(mirror.local_ref) + end + end - new_revision = git.rev_parse(new_revision) - old_revision = mirror.revision + def validate_new_revision(mirror, revision) + if revision.nil? + determine_repository_revision(mirror) + else + new_revision = git.rev_parse(revision) - if new_revision == old_revision - raise InvalidRevision, 'mirror is already at requested revision' - end + if new_revision == mirror.revision + raise InvalidRevision, 'mirror is already at requested revision' + end - new_revision + new_revision + end end def determine_target_revision(mirror, new_revision) git.rev_parse(mirror.versioned_path(new_revision)) end