[LrdeTools] 225: Some last changes before the release.

https://svn.lrde.epita.fr/svn/lrdetools/trunk Index: ChangeLog from Nicolas Pouillard <ertai@lrde.epita.fr> Some last changes before the release. * vcs/lib/vcs/mail.rb: Use --confirm instead of --ask. * vcs/lib/vcs/message.rb: Publish the collaboa url if COLLABOA is defined. * vcs/lib/vcs/changelog.rb: Title and subject are not Yaml anymore. * vcs/lib/vcs/vcs.rb: Update packaging. * vcs/lib/vcs/tools.rb: Remove. * vcs/lib/vcs/svn.rb: Remove a require. * vcs/lib/vcs/mycommit.rb, vcs/lib/vcs/conflict.rb, vcs/lib/vcs/news.rb: Use highline instead of ask. * vcs/bin/vcs: Change the version. Make --mk-alias support bash. * vcs/SPEC.yml: Update dependencies and ttk options. * vcs/test/vcs-check.yml: New. The main test suite. * vcs/test/options-suite.yml: New. A simple test suite for options. SPEC.yml | 5 ++++- bin/vcs | 8 ++++---- lib/vcs/changelog.rb | 9 ++++++--- lib/vcs/conflict.rb | 4 ++-- lib/vcs/edit.rb | 1 + lib/vcs/mail.rb | 2 +- lib/vcs/message.rb | 8 ++++++++ lib/vcs/mycommit.rb | 8 ++++---- lib/vcs/news.rb | 4 ++-- lib/vcs/svn.rb | 1 - lib/vcs/tools.rb | 22 ---------------------- lib/vcs/vcs.rb | 6 +++++- test/options-suite.yml | 38 ++++++++++++++++++++++++++++++++++++++ test/vcs-check.yml | 8 ++++++++ 14 files changed, 83 insertions(+), 41 deletions(-) Index: vcs/lib/vcs/tools.rb --- vcs/lib/vcs/tools.rb (revision 224) +++ vcs/lib/vcs/tools.rb (working copy) @@ -1,22 +0,0 @@ -# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. -# License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ - -require 'yaml' -module YAML - - def self.chop_header ( io ) - aStr = io.gets - raise Exception, "First line is not valid: `#{aLine}'" unless aStr =~ /^---/ - io.each do |aLine| - break if aLine =~ /^---/ - aStr += aLine - end - YAML::load(aStr) - end - -end # module YAML - Index: vcs/bin/vcs --- vcs/bin/vcs (revision 224) +++ vcs/bin/vcs (working copy) @@ -16,7 +16,7 @@ require 'optparse' require 'set' -VCS_VERSION = '0.2.148' +VCS_VERSION = '0.3.0' VCS_PATH = Pathname.new(__FILE__).expand_path VCS_DIR, VCS = VCS_PATH.split LIB = VCS_DIR + '..' + 'lib' @@ -79,13 +79,13 @@ exit end - opts.on('--mk-alias', 'Use this command like that `vcs --mk-alias`') do + opts.on('--mk-alias', 'Put the result of this command in your .zshrc or .bashrc') do ALL_VCS_NAMES.each do |n| n = n.to_s.downcase if VCS_PATH.executable? - puts "alias #{n}=#{VCS_PATH}-#{n}" + puts "alias #{n}=#{VCS_PATH}-#{n} ;" else - puts "alias #{n}=vcs-#{n}" + puts "alias #{n}=vcs-#{n} ;" end end exit Index: vcs/lib/vcs/news.rb --- vcs/lib/vcs/news.rb (revision 224) +++ vcs/lib/vcs/news.rb (working copy) @@ -70,9 +70,9 @@ server, port = opt[:server].split(/:/) port ||= 119 LOG.info('news') { "Nntp Server: #{server}:#{port}" } - if ask("Post a news, with this subject: #{opt[:subject]}\n" + + unless @h.agree("Post a news, with this subject: #{opt[:subject]}\n" + " to #{opt[:groups].join(', ')}\n from #{opt[:from]}\n" + - 'Are you sure?', :y) == :n + 'Are you sure? (y/n)', true) LOG.error('news') { 'Aborting' } exit end Index: vcs/lib/vcs/mail.rb --- vcs/lib/vcs/mail.rb (revision 224) +++ vcs/lib/vcs/mail.rb (working copy) @@ -10,7 +10,7 @@ MAIL = Sendmail::MAIL_FILE MAILER = Sendmail.new - DEFAULT_OPTIONS = %w[ --ask --sign --mime ] + DEFAULT_OPTIONS = %w[ --confirm --sign --mime ] # # Mail. Index: vcs/SPEC.yml --- vcs/SPEC.yml (revision 224) +++ vcs/SPEC.yml (working copy) @@ -32,4 +32,7 @@ executables: [ vcs, vcs-svn, vcs-cvs, vcs-prcs ] dependencies: - ruby_ex: ~> 0.1.3 + ruby_ex: [~> 0.2.0, 6087/ruby_ex-0.2.0.tar.gz] + +root_test_suite: test/vcs-check.yml +ttk_version: ~> 0.3.0 Index: vcs/test/vcs-check.yml --- vcs/test/vcs-check.yml (revision 0) +++ vcs/test/vcs-check.yml (revision 0) @@ -0,0 +1,8 @@ +--- + +Run all test suites: !S::Iterate + over: !pathlist <<pwd>>/(*)-suite.yml + iter: [it_file, it_name] + test: + Run the <<it_name>> suite: !S::Import + import: <<it_file>> Index: vcs/lib/vcs/changelog.rb --- vcs/lib/vcs/changelog.rb (revision 224) +++ vcs/lib/vcs/changelog.rb (working copy) @@ -64,10 +64,13 @@ raise MustBeFilled, cl if cl.read =~ /\A---/ require 'erb' ls = [] - YAML.each_document(cl.read) { |x| (ls.size == 2)? break : ls << x } - header, input = ls + YAML.each_document("--- |\n" + cl.read) { |x| (ls.size == 2)? break : ls << x } + title_subject, input = ls + header = { 'title' => title_subject[/^title: (.*)$/, 1], + 'subject' => title_subject[/^subject: (.*)$/, 1] } rev = revision.read.to_i + 1 header.merge!('rev' => rev, 'revision' => rev) + raise "no title: reopen #{ADD_CL}" if header['title'].nil? header['title'].sub!(/\.$/, '') b = getBinding(header) header = ERB.new(header.to_yaml, $SAFE, '<-%->', '$erbout_').result(b) @@ -83,7 +86,7 @@ f.puts " |--- | ########## Fill this file correctly and remove this line ########## | --- |title: -|subject: '#{@@subject_format}.' +|subject: #{@@subject_format}. | |--- | ###################### Your ChangeLog entrie ###################### | --- |#{head} Index: vcs/lib/vcs/edit.rb --- vcs/lib/vcs/edit.rb (revision 224) +++ vcs/lib/vcs/edit.rb (working copy) @@ -8,6 +8,7 @@ class Vcs def edit! ( *files ) + # stringify cmd = EDITOR + files.flatten.map { |x| x.to_s } > [STDOUT, STDERR] cmd.run(@runner) end Index: vcs/lib/vcs/conflict.rb --- vcs/lib/vcs/conflict.rb (revision 224) +++ vcs/lib/vcs/conflict.rb (working copy) @@ -12,8 +12,8 @@ def resolve_conflicts! conflicts = mk_conflicts_list - question = "Resolve these conflicts: \n - #{conflicts.join("\n - ")}\n" - if ask(question, :n, STDIN, STDOUT, STDERR) == :y + question = "Resolve these conflicts?: \n - #{conflicts.join("\n - ")}\n(y/n)" + if @h.agree question, true return resolved(conflicts) end end Index: vcs/lib/vcs/svn.rb --- vcs/lib/vcs/svn.rb (revision 224) +++ vcs/lib/vcs/svn.rb (working copy) @@ -6,7 +6,6 @@ # $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' -require 'vcs/tools' CL = Pathname.new('ChangeLog') ADD_CL = Pathname.new(',ChangeLog') Index: vcs/lib/vcs/mycommit.rb --- vcs/lib/vcs/mycommit.rb (revision 224) +++ vcs/lib/vcs/mycommit.rb (working copy) @@ -6,7 +6,6 @@ # $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' -require 'ask' class Vcs @@ -32,7 +31,7 @@ edit! @@message - if ask('Committing, are you sure?', :y) == :n + unless @h.agree 'Committing, are you sure? (y/n)', true commit_failed end @@ -45,10 +44,11 @@ # FIXME simplify cl_entry contents - if commit!('--message', cl_entry, *(opts + args)) + begin + commit!('--message', cl_entry, *(opts + args)) ADD_CL.rename(COMMITED) TMP_CL.delete if TMP_CL.exist? - else + rescue commit_failed end Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 224) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -7,7 +7,9 @@ require 'rubygems' require_gem 'ruby_ex' -require 'commands' +require 'ruby_ex' +Commands.import! +Yaml::ChopHeader.import! # The abstract class for a Vcs wrapper. # Conventions: @@ -52,6 +54,7 @@ end def new_command_data + @__instance.status = nil @__instance end @@ -61,6 +64,7 @@ @cmd = aCmd.to_cmd @handlers = Set.new @runner = Commands::Runners::System.new + @h = HighLine.new self.cmd_data_factory = VcsCmdDataFactory.new(:output => STDOUT, :error => STDERR) @runner.subscribe_hook(:failure) do |data| Index: vcs/test/options-suite.yml --- vcs/test/options-suite.yml (revision 0) +++ vcs/test/options-suite.yml (revision 0) @@ -0,0 +1,38 @@ +--- + +Check vcs basic options: !S::Suite + + # What have these test in common + attributes: !S::Cmd # All of them follow the Cmd strategy + command: <<pwd>>/../bin/vcs # They test the same command + exit : 0 # They expect 0 as exit status + error : "" # By default we don't want anything on stderr + + contents: + + - Check the version option: + args: --version # Give --version as arguement + output: !re | # Output will be compared to this regexp + Vcs version: \d+.\d+.\d+ + + - Check the help option: + args: --help + output: "" # Output must be empty + error: | # Stderr output will be compared to this string + Usage: vcs [options] <file>* + + -c, --vcs TYPE Set your vcs + -l, --vcs-list List all vcs + --mk-alias Put the result of this command in your .zshrc or .bashrc + -C, --[no-]check Check your vcs configuration + -d, --debug LEVEL Set debug level + -h, --help Show this message + --version Show version + + + Report bugs to <ertai@lrde.epita.fr>. + + - Check the mk-alias option: + args: --mk-alias + # Output will be compared to this regexp + output: !re \A(^alias \w+=.* ;$)+ Index: vcs/lib/vcs/message.rb --- vcs/lib/vcs/message.rb (revision 224) +++ vcs/lib/vcs/message.rb (working copy) @@ -43,6 +43,14 @@ TempPath.new('message') do |tmp| tmp.open('w') do |f| with(f).url! + if defined? COLLABOA + f.puts + f.puts 'You can also view this changeset here:' + f.puts + next_rev = rev.output.read.to_i + next_rev += 1 unless ',commited'.to_path.exist? + f.puts "http://#{COLLABOA}/repository/changesets/#{next_rev}" + end f.puts f.puts 'Index: ChangeLog' f.print cl_entry.sub(/^\d+-\d+-\d+/, 'from')
participants (1)
-
Nicolas Pouillard