Sha256: aa214032d883e99b218a18171ae35145b069ea5a34ec1893c56d420474d1b386
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
module Braid class Command class InvalidRevision < BraidError end extend Operations::VersionControl include Operations::VersionControl def self.run(command, *args) verify_git_version! klass = Commands.const_get(command.to_s.capitalize) klass.new.run(*args) rescue BraidError => error case error when Operations::ShellExecutionError msg "Shell error: #{error.message}" else msg "Error: #{error.message}" end exit(1) end def self.msg(str) puts "Braid: #{str}" end def msg(str) self.class.msg(str) end def config @config ||= Config.new end def verbose? Braid.verbose end def force? Braid.force end private def setup_remote(mirror) Command.run(:setup, mirror.path) end def use_local_cache? Braid.use_local_cache end def self.verify_git_version! git.require_version!(REQUIRED_GIT_VERSION) end def bail_on_local_changes! git.ensure_clean! end def with_reset_on_error work_head = git.head begin yield rescue => error msg "Resetting to '#{work_head[0, 7]}'." git.reset_hard(work_head) raise error end end def add_config_file git.add(CONFIG_FILE) end 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) unless new_revision new_revision = git.rev_parse(new_revision) old_revision = mirror.revision if new_revision == old_revision raise InvalidRevision, "mirror is already at requested revision" end new_revision end def determine_target_revision(new_revision) git.rev_parse(new_revision) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
realityforge-braid-0.9.1 | lib/braid/command.rb |