Class: Autoproj::CLI::Log

Inherits:
Base
  • Object
show all
Defined in:
lib/autoproj/cli/log.rb

Instance Attribute Summary

Attributes inherited from Base

#ws

Instance Method Summary collapse

Methods inherited from Base

#export_env_sh, #initialize, #normalize_command_line_package_selection, #notify_env_sh_updated, #resolve_selection, #resolve_user_selection, validate_options, #validate_options, #validate_user_selection

Methods included from Ops::Tools

#common_options, #create_autobuild_package, #load_autoprojrc, #load_main_initrb

Constructor Details

This class inherits a constructor from Autoproj::CLI::Base

Instance Method Details

#parse_log_entry(entry) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/autoproj/cli/log.rb', line 30

def parse_log_entry(entry)
    if entry =~ /^autoproj@{\d+}$/
        entry
    elsif entry =~ /^\d+$/
        "autoproj@{#{entry}}"
    else
        raise CLIInvalidArguments, "unexpected revision name '#{entry}', expected either autoproj@{ID} or ID ('ID' being a number). Run 'autoproj log' without arguments for a list of known entries"
    end
end

#run(args, options = Hash.new) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/autoproj/cli/log.rb', line 6

def run(args, options = Hash.new)
    ws.load_config

    if !ws.config.import_log_enabled?
        Autoproj.error "import log is disabled on this install"
        return
    elsif !Ops::Snapshot.update_log_available?(ws.manifest)
        Autoproj.error "import log is not available on this install, the main build configuration repository is not using git"
        return
    end

    common_args = [Autobuild.tool(:git), "--git-dir=#{ws.config_dir}/.git"]
    if (since = options[:since])
        exec(*common_args, "diff", parse_log_entry(since), "autoproj@{0}")
    elsif args.empty?
        exec(*common_args, "reflog",
             Ops::Snapshot.import_state_log_ref, "--format=%Cgreen%gd %Cblue%cr %Creset%gs")
    elsif options[:diff]
        exec(*common_args, "diff", *args.map { |entry| parse_log_entry(entry) })
    else
        exec(*common_args, "show", *args.map { |entry| parse_log_entry(entry) })
    end
end