Class: Tetra::ChangeSourcesSubcommand

Inherits:
Subcommand
  • Object
show all
Defined in:
lib/tetra/ui/change_sources_subcommand.rb

Overview

tetra change-sources

Instance Method Summary collapse

Methods inherited from Subcommand

#bypass_parsing, #checking_exceptions, #configure_log_level, #ensure_dry_running, #format_path, #print_generation_result, #verbose=, #very_verbose=, #very_very_verbose=

Methods included from Logging

#log

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tetra/ui/change_sources_subcommand.rb', line 11

def execute
  checking_exceptions do
    # Ensure the user provided an archive OR explicitly opted out
    if source_archive.nil? && !no_archive?
      signal_usage_error "please specify a source archive file or use \"--no-archive\" (see SPECIAL_CASES.md)."
    end

    project = Tetra::Project.new(".")
    ensure_dry_running(:is_not_in_progress, project) do
      if !no_archive?
        # CASE 1: Updating from a new archive file
        full_archive_path = File.expand_path(source_archive)
        project.commit_source_archive(full_archive_path, message)

        puts "New sources committed."
        puts "Please delete any stale source archives from packages/ before proceeding."
      else
        # CASE 2: Updating from manual changes in src/
        project.commit_sources(message, true)

        puts "New sources committed."
        puts "Please copy source archive(s) corresponding to src/ in packages/ before proceeding."
      end
    end
  end
end