Sha256: 57c56fa8e3ec68f2d6e8c4f0e521503d27b1b1aa648394cbdd61bcdcde067152

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'autoproj/cli/base'

module Autoproj
    module CLI
        class Log < Base
            def run(args, options = Hash.new)
                ws = Workspace.from_environment
                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

            def parse_log_entry(entry)
                if entry =~ /^autoproj@{\d+}$/
                    entry
                elsif entry =~ /^\d+$/
                    "autoproj@{#{entry}}"
                else
                    raise ArgumentError, "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
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
autoproj-2.3.1 lib/autoproj/cli/log.rb
autoproj-2.3.0 lib/autoproj/cli/log.rb