lib/autoproj/cli/commit.rb in autoproj-2.4.0 vs lib/autoproj/cli/commit.rb in autoproj-2.5.0.pre1
- old
+ new
@@ -3,37 +3,52 @@
require 'autoproj/ops/snapshot'
module Autoproj
module CLI
class Commit < InspectionTool
- def run(*user_selection, options = Hash.new)
- pkg = manifest.main_package_set.create_autobuild_package
+ def default_message(tag_name)
+ if tag_name
+ "autoproj created tag #{tag_name}"
+ else
+ 'autoproj created version commit'
+ end
+ end
+
+ def run(user_selection, options = Hash.new)
+ tag_name = options[:tag]
+ ws.load_config
+ pkg = ws.manifest.main_package_set.create_autobuild_package
importer = pkg.importer
if !importer || !importer.kind_of?(Autobuild::Git)
- raise CLIInvalidArguments, "cannot use autoproj tag if the main configuration is not managed by git"
+ raise CLIInvalidArguments, "cannot use autoproj commit if the main configuration is not managed by git"
end
- versions_file = File.join(
- ws.config_dir,
- Workspace::OVERRIDES_DIR,
- Versions::DEFAULT_VERSIONS_FILE_BASENAME)
+ if tag_name
+ begin
+ importer.rev_parse(pkg, "refs/tags/#{tag_name}")
+ raise CLIInvalidArguments, "tag #{tag_name} already exists"
+ rescue Autobuild::PackageException
+ end
+ end
- initialize_and_load
+ versions_file = File.join(ws.config_dir,
+ Workspace::OVERRIDES_DIR,
+ Versions::DEFAULT_VERSIONS_FILE_BASENAME)
versions = CLI::Versions.new(ws)
Autoproj.message "creating versions file, this may take a while"
versions.run(user_selection,
- save: File.join(ws.config_dir, versions_file),
+ save: versions_file,
package_sets: options[:package_sets],
- output_file: io.path,
replace: true,
- keep_going: options[:keep_going])
+ keep_going: options[:keep_going],
+ deps: options[:deps])
importer.run_git(pkg, 'add', versions_file)
- message = options[:message] ||
- "autoproj created tag #{tag_name}"
+ message = options[:message] || default_message(tag_name)
importer.run_git(pkg, 'commit', '-m', message)
+ importer.run_git(pkg, 'tag', tag_name) unless tag_name.nil?
end
end
end
end