Skip to content

Commit

Permalink
add ability to set git versions on the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
maguec committed May 30, 2014
1 parent b66914c commit ee6affc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/omnibus/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def initialize(args, options, config)
Omnibus.logger.level = @options[:log_level]
end

# If there are any version changes then go ahead and update them
@options[:version].each do |key, value|
Config.version_override[key] = value
end

# Do not load the Omnibus config if we are asking for help or the version
if %w(help version).include?(config[:current_command].name)
log.debug { 'Skipping Omnibus loading (detected help or version)' }
Expand Down Expand Up @@ -99,6 +104,10 @@ def initialize(args, options, config)
aliases: '-o',
type: :hash,
default: {}
class_option :version,
desc: 'Override the project version send project:version',
aliases: '-v',
type: :hash

#
# Hide the default help task to encourage people to use +-h+ instead of
Expand Down
7 changes: 7 additions & 0 deletions lib/omnibus/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ class Config
# @return [Array]
default :ldd_whitelist_override, []

# @!attribute [rw] version_override
# manually override the project version on the command line
#
# @return [Hash]
default :version_override, {}


# # @!endgroup

# @!group Build Control Parameters
Expand Down
8 changes: 7 additions & 1 deletion lib/omnibus/fetchers/git_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ class GitFetcher < Fetcher
def initialize(software)
@name = software.name
@source = software.source
@version = software.version

if Config.version_override.has_key? software
@version = Config.version_override[software]
else
@version = software.version
end

@project_dir = software.project_dir
super
end
Expand Down

0 comments on commit ee6affc

Please sign in to comment.