vcs 0.1 → 0.2.148
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -3
- data/bin/vcs +57 -34
- data/doc/jamis.rb +564 -0
- data/ruby_ex/abstract.rb +254 -0
- data/ruby_ex/abstract_node.rb +85 -0
- data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
- data/ruby_ex/array_each_pair.rb +18 -0
- data/ruby_ex/ask.rb +101 -0
- data/ruby_ex/attributed_class.rb +302 -0
- data/ruby_ex/cache.rb +373 -0
- data/ruby_ex/checkout.rb +12 -0
- data/ruby_ex/choose.rb +271 -0
- data/ruby_ex/commands.rb +18 -0
- data/ruby_ex/commands/command.rb +401 -0
- data/ruby_ex/commands/datas.rb +16 -0
- data/ruby_ex/commands/datas/data.rb +33 -0
- data/ruby_ex/commands/datas/factory.rb +66 -0
- data/ruby_ex/commands/factory.rb +66 -0
- data/ruby_ex/commands/helpers.rb +67 -0
- data/ruby_ex/commands/pipe.rb +64 -0
- data/ruby_ex/commands/runners.rb +17 -0
- data/ruby_ex/commands/runners/exec.rb +49 -0
- data/ruby_ex/commands/runners/fork.rb +97 -0
- data/ruby_ex/commands/runners/runner.rb +107 -0
- data/ruby_ex/commands/seq.rb +27 -0
- data/ruby_ex/config_file.rb +96 -0
- data/ruby_ex/const_regexp.rb +59 -0
- data/ruby_ex/daemon.rb +134 -0
- data/ruby_ex/diff.rb +667 -0
- data/ruby_ex/dlogger.rb +62 -0
- data/ruby_ex/drb/dispatcher.rb +252 -0
- data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
- data/ruby_ex/drb/drb_observable.rb +97 -0
- data/ruby_ex/drb/drb_observable_pool.rb +27 -0
- data/ruby_ex/drb/drb_service.rb +43 -0
- data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
- data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
- data/ruby_ex/drb/session_client_test.rb +40 -0
- data/ruby_ex/drb/session_manager.rb +246 -0
- data/ruby_ex/drb/session_server.rb +53 -0
- data/ruby_ex/dtime.rb +143 -0
- data/ruby_ex/dumpable_proc.rb +63 -0
- data/ruby_ex/exception.rb +32 -0
- data/ruby_ex/filetype.rb +229 -0
- data/ruby_ex/fileutils_ex.rb +44 -0
- data/ruby_ex/fold.rb +58 -0
- data/ruby_ex/generate_id.rb +44 -0
- data/ruby_ex/hookable.rb +262 -0
- data/ruby_ex/hooker.rb +54 -0
- data/ruby_ex/inactive_timeout.rb +137 -0
- data/ruby_ex/indexed_node.rb +66 -0
- data/ruby_ex/io_marshal.rb +100 -0
- data/ruby_ex/ioo.rb +194 -0
- data/ruby_ex/labeled_node.rb +63 -0
- data/ruby_ex/logger_observer.rb +23 -0
- data/ruby_ex/md5sum.rb +66 -0
- data/ruby_ex/mktemp.rb +208 -0
- data/ruby_ex/module/attr_once.rb +36 -0
- data/ruby_ex/module/autoload_tree.rb +75 -0
- data/ruby_ex/module/hierarchy.rb +335 -0
- data/ruby_ex/module/instance_method_visibility.rb +73 -0
- data/ruby_ex/module_ex.rb +11 -0
- data/ruby_ex/node.rb +80 -0
- data/ruby_ex/object_monitor.rb +145 -0
- data/ruby_ex/object_monitor_activity.rb +33 -0
- data/ruby_ex/observable.rb +140 -0
- data/ruby_ex/observable_pool.rb +293 -0
- data/ruby_ex/orderedhash.rb +252 -0
- data/ruby_ex/pathname_ex.rb +152 -0
- data/ruby_ex/pp_hierarchy.rb +29 -0
- data/ruby_ex/pseudo_cache.rb +190 -0
- data/ruby_ex/queue.rb +56 -0
- data/ruby_ex/random_generators.rb +25 -0
- data/ruby_ex/random_generators/random_generator.rb +31 -0
- data/ruby_ex/random_generators/ruby.rb +23 -0
- data/ruby_ex/safe_eval.rb +348 -0
- data/ruby_ex/sendmail.rb +215 -0
- data/ruby_ex/service_manager.rb +121 -0
- data/ruby_ex/session/administrable.rb +120 -0
- data/ruby_ex/session/client.rb +153 -0
- data/ruby_ex/session/const.rb +18 -0
- data/ruby_ex/session/dispatcher.rb +184 -0
- data/ruby_ex/session/error.rb +21 -0
- data/ruby_ex/session/fetchable.rb +57 -0
- data/ruby_ex/session/fetcher.rb +62 -0
- data/ruby_ex/session/hookable.rb +26 -0
- data/ruby_ex/session/profile.rb +110 -0
- data/ruby_ex/session/server.rb +582 -0
- data/ruby_ex/session/test/administrable_test.rb +337 -0
- data/ruby_ex/session/test/basic_test.rb +523 -0
- data/ruby_ex/session/test/dispatcher_test.rb +409 -0
- data/ruby_ex/session/test/fetchable_test.rb +119 -0
- data/ruby_ex/session/test/sub_server_test.rb +188 -0
- data/ruby_ex/shuffle.rb +30 -0
- data/ruby_ex/spring.rb +136 -0
- data/ruby_ex/spring_set.rb +137 -0
- data/ruby_ex/string_ex.rb +28 -0
- data/ruby_ex/symtbl.rb +106 -0
- data/ruby_ex/synflow.rb +474 -0
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
- data/ruby_ex/thread_mutex.rb +10 -0
- data/ruby_ex/timeout_ex.rb +81 -0
- data/ruby_ex/top_down.rb +73 -0
- data/ruby_ex/trace.rb +26 -0
- data/ruby_ex/uri/druby.rb +81 -0
- data/ruby_ex/uri/file.rb +65 -0
- data/ruby_ex/uri/ftp_ex.rb +37 -0
- data/ruby_ex/uri/http_ex.rb +43 -0
- data/ruby_ex/uri/ssh.rb +92 -0
- data/ruby_ex/uri/svn.rb +118 -0
- data/ruby_ex/uri_ex.rb +45 -0
- data/ruby_ex/verbose_object.rb +30 -0
- data/ruby_ex/version.rb +66 -0
- data/ruby_ex/yaml/basenode_ext.rb +63 -0
- data/ruby_ex/yaml/chop_header.rb +23 -0
- data/ruby_ex/yaml/transform.rb +449 -0
- data/ruby_ex/yaml/yregexpath.rb +76 -0
- data/src/changelog.rb +28 -18
- data/src/conflict.rb +20 -0
- data/src/diff.rb +18 -0
- data/src/diffstat.rb +9 -3
- data/src/last_changed_date.rb +18 -0
- data/src/mail.rb +33 -65
- data/src/message.rb +15 -9
- data/src/mycommit.rb +29 -14
- data/src/news.rb +24 -3
- data/src/status.rb +17 -0
- data/src/svn.rb +2 -2
- data/src/vcs.rb +24 -3
- metadata +124 -5
- data/lrdetools.rb +0 -12
@@ -0,0 +1,76 @@
|
|
1
|
+
# Author:: Marco Tessari <marco.tessari@epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004 TTK Team. All rights reserved.
|
3
|
+
# License:: Ruby license.
|
4
|
+
|
5
|
+
# $LastChangedBy: polrop $
|
6
|
+
# $Id: yregexpath.rb 159 2005-02-18 12:07:23Z polrop $
|
7
|
+
|
8
|
+
module YAML
|
9
|
+
|
10
|
+
class YRegexPath
|
11
|
+
attr_reader :segments, :root, :wanted_node_index
|
12
|
+
|
13
|
+
def initialize ( str )
|
14
|
+
raise ArgumentError, 'Argument must be a string' unless str.is_a?(String)
|
15
|
+
@segments = []
|
16
|
+
@wanted_node_index = nil
|
17
|
+
@root = (str[0] == ?/)
|
18
|
+
while str =~ /^(\/|#)?((?:(?:\\.)|[^\\=\/#])+)(?:=((?:(?:\\.)|[^\\\/#])*))?/
|
19
|
+
if ($1 == "#")
|
20
|
+
if (@wanted_node_index.nil?)
|
21
|
+
@wanted_node_index = @segments.length
|
22
|
+
else
|
23
|
+
raise ArgumentError, 'More than a "#" given.'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
if ($3.nil?)
|
27
|
+
@segments << Regexp.new($2)
|
28
|
+
else
|
29
|
+
@segments << [ Regexp.new($2), Regexp.new($3) ]
|
30
|
+
end
|
31
|
+
str = $'
|
32
|
+
end
|
33
|
+
@wanted_node_index = @segments.length if @wanted_node_index.nil?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end # module YAML
|
38
|
+
|
39
|
+
if defined? TEST_MODE or $0 == __FILE__
|
40
|
+
|
41
|
+
require 'test/unit'
|
42
|
+
|
43
|
+
class YRegexPathTest < Test::Unit::TestCase
|
44
|
+
def compare(str, tab)
|
45
|
+
tab.collect! do |e|
|
46
|
+
if (e.is_a?(Array))
|
47
|
+
e.collect! { |s| Regexp.new(s) unless s.nil? }
|
48
|
+
else
|
49
|
+
Regexp.new(e)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
desc = "Compare #{str} with #{tab}."
|
53
|
+
assert_equal(tab, YAML::YRegexPath.new(str).segments, desc)
|
54
|
+
end
|
55
|
+
|
56
|
+
def testit
|
57
|
+
compare('mho', [ 'mho' ])
|
58
|
+
compare('mho\\', [ 'mho' ])
|
59
|
+
compare('/mho', [ 'mho' ])
|
60
|
+
compare('/mho=42', [ [ 'mho', '42'] ])
|
61
|
+
compare('/mho=[0-9]+', [ [ 'mho', '[0-9]+' ] ])
|
62
|
+
compare('m\/ho', [ 'm\/ho' ])
|
63
|
+
compare('mho/foo', [ 'mho', 'foo' ])
|
64
|
+
compare('mho=35/foo=test', [ [ 'mho' , '35' ], [ 'foo' , 'test' ] ])
|
65
|
+
compare('test#status=PASS', [ 'test' , [ 'status' , 'PASS' ] ])
|
66
|
+
compare('mho#', [ 'mho' ])
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_errors
|
70
|
+
# Build with something else than a String.
|
71
|
+
assert_raise(ArgumentError) { YAML::YRegexPath.new(42) }
|
72
|
+
# Two '#'.
|
73
|
+
assert_raise(ArgumentError) { YAML::YRegexPath.new('1#2#3') }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/src/changelog.rb
CHANGED
@@ -14,8 +14,8 @@ class Svn
|
|
14
14
|
{
|
15
15
|
'A' => 'New',
|
16
16
|
'D' => 'Remove',
|
17
|
-
'M' => ''
|
18
17
|
}
|
18
|
+
@@file_st.default = ''
|
19
19
|
|
20
20
|
@@prop_st =
|
21
21
|
{
|
@@ -24,16 +24,13 @@ class Svn
|
|
24
24
|
|
25
25
|
def mkchangelog_from_status ( *args )
|
26
26
|
result = []
|
27
|
-
|
28
|
-
next
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
str += (file_st.nil?) ? prop_st : (', ' + prop_st.downcase) if prop_st
|
35
|
-
result << [file, str]
|
36
|
-
end
|
27
|
+
from_status(*args) do |line, file_st, prop_st, copy_st, file|
|
28
|
+
next if file_st =~ /[?X]/
|
29
|
+
next if file == 'ChangeLog'
|
30
|
+
ls = []
|
31
|
+
ls << @@file_st[file_st] if @@file_st.has_key? file_st
|
32
|
+
ls << @@prop_st[prop_st].downcase if @@prop_st.has_key? prop_st
|
33
|
+
result << [file, ls.join(', ')]
|
37
34
|
end
|
38
35
|
raise Failure, 'No changes, so no ChangeLog entry.' if result.empty?
|
39
36
|
result
|
@@ -54,6 +51,8 @@ class Vcs
|
|
54
51
|
end
|
55
52
|
|
56
53
|
def mkchangelog ( *args )
|
54
|
+
error_handling :changelog_failed
|
55
|
+
|
57
56
|
cl = ADD_CL
|
58
57
|
|
59
58
|
if cl.exist?
|
@@ -68,7 +67,7 @@ class Vcs
|
|
68
67
|
LOG.warn "Creating a new `#{cl}' file"
|
69
68
|
cl.open('w') do |f|
|
70
69
|
f.puts '=== Fill this file correctly and remove this line ==='
|
71
|
-
f.puts
|
70
|
+
f.puts Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}")
|
72
71
|
f.puts
|
73
72
|
cl_add.each do |file, str|
|
74
73
|
f.puts "\t* #{file}: #{str}."
|
@@ -79,29 +78,40 @@ class Vcs
|
|
79
78
|
raise MustBeFilled, cl
|
80
79
|
end
|
81
80
|
|
82
|
-
def
|
81
|
+
def concat_changelog! ( *args )
|
82
|
+
error_handling :changelog_failed
|
83
|
+
|
83
84
|
unless CL.exist?
|
84
|
-
raise Failure,
|
85
|
+
raise Failure, "No `#{CL}', you are probably not in a valid directory."
|
85
86
|
end
|
86
87
|
|
87
88
|
if cl = mkchangelog(*args)
|
88
89
|
|
89
90
|
unless TMP_CL.exist?
|
90
|
-
LOG.
|
91
|
+
LOG.info "Moving `#{CL}' to `#{TMP_CL}' ..."
|
91
92
|
CL.rename(TMP_CL)
|
92
93
|
end
|
93
94
|
|
94
95
|
CL.open('w') do |file|
|
95
|
-
|
96
|
+
LOG.info "Prepending `#{ADD_CL}' to `#{CL}' ..."
|
97
|
+
file.print cl.read
|
96
98
|
file.puts
|
97
|
-
|
99
|
+
file.print TMP_CL.read
|
98
100
|
end
|
99
101
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
105
|
+
def changelog_failed
|
106
|
+
if TMP_CL.exist?
|
107
|
+
LOG.info "Restoring `#{CL}' from `#{TMP_CL}' ..."
|
108
|
+
TMP_CL.rename(CL)
|
109
|
+
end
|
110
|
+
LOG.info "#{ADD_CL}: Contains your ChangeLog entry" if ADD_CL.exist?
|
111
|
+
end
|
112
|
+
|
103
113
|
alias_command :mkcl, :mkchangelog
|
104
|
-
alias_command :
|
114
|
+
alias_command :ctcl, :concat_changelog
|
105
115
|
|
106
116
|
end # class Vcs
|
107
117
|
|
data/src/conflict.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
class Vcs
|
2
|
+
|
3
|
+
def mk_conflicts_list
|
4
|
+
status.grep(/^C/).each { |s| s.sub!(/^C\s+(.*)\n/, '\1') }
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit_conflicts
|
8
|
+
system("#{EDITOR} #{mk_conflicts_list}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def resolve_conflicts
|
12
|
+
conflicts = mk_conflicts_list
|
13
|
+
question = "Resolve these conflicts: \n - #{conflicts.join("\n - ")}\n"
|
14
|
+
if ask(question, :n) == :y
|
15
|
+
return resolved(conflicts)
|
16
|
+
end
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
|
20
|
+
end # class Vcs
|
data/src/diff.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
|
3
|
+
# License:: GNU General Public License (GPL).
|
4
|
+
# Revision:: $Id$
|
5
|
+
|
6
|
+
class Svn
|
7
|
+
|
8
|
+
def diffw_from_status ( *args )
|
9
|
+
files = Set.new
|
10
|
+
from_status(*args) do |line, file_st, prop_st, cpy, file|
|
11
|
+
next if file_st =~ /[?X]/
|
12
|
+
next if file == 'ChangeLog'
|
13
|
+
files << Pathname.new(file)
|
14
|
+
end
|
15
|
+
diffw(*files.delete_if { |f| f.directory? })
|
16
|
+
end
|
17
|
+
|
18
|
+
end # class Svn
|
data/src/diffstat.rb
CHANGED
@@ -12,9 +12,7 @@ class Vcs
|
|
12
12
|
# Use the diffstat command to
|
13
13
|
# display statitics on your patch.
|
14
14
|
def diffstat ( *a )
|
15
|
-
|
16
|
-
raise ArgumentError, 'The `diffstat\' tool is needed by Vcs.diffstat'
|
17
|
-
end
|
15
|
+
check_diffstat
|
18
16
|
patch = diff(*a)
|
19
17
|
rd, wr = IO.pipe
|
20
18
|
pid = fork do
|
@@ -32,5 +30,13 @@ class Vcs
|
|
32
30
|
end
|
33
31
|
alias_command :ds, :diffstat
|
34
32
|
|
33
|
+
def check_diffstat
|
34
|
+
unless `diffstat -V` =~ /diffstat version/
|
35
|
+
raise ArgumentError, 'The `diffstat\' tool is needed by Vcs.diffstat'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
add_conf_checker :check_diffstat
|
40
|
+
|
35
41
|
end # class Vcs
|
36
42
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
|
+
# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
|
3
|
+
# License:: GNU General Public License (GPL).
|
4
|
+
# $Id$
|
5
|
+
|
6
|
+
require 'svn'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
class Svn
|
10
|
+
|
11
|
+
def last_changed_date ( *args )
|
12
|
+
re = /^Last Changed Date:.*?\(([^)]*)\).*$/
|
13
|
+
StringIO.new(info.readlines.grep(/^Last Changed Date:/).first.sub(re, '\1'))
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_command :date, :last_changed_date
|
17
|
+
|
18
|
+
end # class Svn
|
data/src/mail.rb
CHANGED
@@ -1,83 +1,51 @@
|
|
1
|
-
# Author::
|
1
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
2
2
|
# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
|
3
|
-
# License::
|
4
|
-
|
5
|
-
# $LastChangedBy: ertai $
|
6
|
-
# $Id: header 98 2004-09-29 12:07:43Z ertai $
|
3
|
+
# License:: GNU General Public License (GPL).
|
4
|
+
# Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $
|
7
5
|
|
8
6
|
require 'vcs'
|
9
|
-
require '
|
7
|
+
require 'sendmail'
|
10
8
|
|
11
9
|
class Vcs
|
12
10
|
|
13
|
-
MAIL =
|
14
|
-
|
15
|
-
|
16
|
-
require 'optparse'
|
17
|
-
result =
|
18
|
-
{
|
19
|
-
:from => FULL_EMAIL,
|
20
|
-
:to => [],
|
21
|
-
:server => ENV['SMTPSERVER'] || 'localhost',
|
22
|
-
}
|
23
|
-
if !args.nil? and !args.empty? and args[0].is_a?(Hash)
|
24
|
-
args[0].each do |k,v|
|
25
|
-
result[k] = v
|
26
|
-
end
|
27
|
-
return result
|
28
|
-
end
|
29
|
-
OptionParser.new do |opts|
|
30
|
-
opts.separator ''
|
31
|
-
opts.on('-t', '--mail-to NAME', 'Choose a recipient') do |aString|
|
32
|
-
result[:to] << aString
|
33
|
-
end
|
34
|
-
opts.on('-s', '--server NAME', 'Choose a mail server') do |aString|
|
35
|
-
result[:server] = aString
|
36
|
-
end
|
37
|
-
opts.on('-S', '--subject NAME', 'Choose your mail subject') do |aString|
|
38
|
-
result[:subject] = aString.sub(/\.?$/, '.')
|
39
|
-
end
|
40
|
-
opts.on_tail('-h', '--help', 'Show this message') do
|
41
|
-
puts opts
|
42
|
-
exit
|
43
|
-
end
|
44
|
-
end.parse!(args)
|
45
|
-
raise Failure, 'No recipents' if result[:to].empty?
|
46
|
-
raise Failure, 'No mail server' if result[:server].nil?
|
47
|
-
raise Failure, 'No mail subject' if result[:subject].nil?
|
48
|
-
result
|
49
|
-
end
|
50
|
-
protected :parse_mail_options
|
11
|
+
MAIL = Sendmail::MAIL_FILE
|
12
|
+
MAILER = Sendmail.new
|
13
|
+
DEFAULT_OPTIONS = %w[ --ask --sign --mime ]
|
51
14
|
|
52
15
|
#
|
53
16
|
# Mail.
|
54
17
|
#
|
55
18
|
def mail ( *args )
|
19
|
+
error_handling :mail_failed
|
20
|
+
unless MAIL.exist?
|
21
|
+
print_body(MAIL, MAILER.parse_mail_options(*(DEFAULT_OPTIONS + args)))
|
22
|
+
end
|
23
|
+
MAILER.sendmail
|
24
|
+
MAIL.delete
|
25
|
+
StringIO.new('Mail: Sent.')
|
26
|
+
end
|
56
27
|
|
57
|
-
|
28
|
+
def mail_failed
|
29
|
+
if defined? MAIL and MAIL.exist?
|
30
|
+
LOG.info "#{MAIL}: Contains the generated mail " +
|
31
|
+
"(generated from #{@@message})"
|
32
|
+
end
|
33
|
+
end
|
58
34
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
" to #{opt[:to].join(', ')}\n from #{opt[:from]}\n" +
|
64
|
-
'Are you sure?', :y) == :n
|
65
|
-
LOG.error 'Aborting'
|
66
|
-
exit
|
67
|
-
end
|
68
|
-
require 'net/smtp'
|
69
|
-
Net::SMTP.start(opt[:server], 25) do |smtp|
|
70
|
-
smtp.open_message_stream(EMAIL, opt[:to]) do |f|
|
71
|
-
f.print "From: #{opt[:from]}\n"
|
72
|
-
f.print "Subject: #{opt[:subject]}\n"
|
73
|
-
f.print "To: #{opt[:to].join(', ')}\n"
|
74
|
-
f.print "\n"
|
75
|
-
file.each { |line| f.print line }
|
76
|
-
end
|
35
|
+
def mail_conf_checker
|
36
|
+
%w[ EMAIL FULLNAME SMTPSERVER ].each do |var|
|
37
|
+
if ENV[var].nil? or ENV[var].empty?
|
38
|
+
LOG.error "environment variable `#{var}' not set"
|
77
39
|
end
|
78
40
|
end
|
79
|
-
|
80
|
-
|
41
|
+
unless `gpg --version` =~ /^gpg \(GnuPG\)/
|
42
|
+
LOG.error 'command not found: gpg'
|
43
|
+
end
|
44
|
+
unless File.exist?("#{ENV['HOME']}/.gnupg/secring.gpg")
|
45
|
+
LOG.error 'no private key: in your ~/.gnupg'
|
46
|
+
end
|
81
47
|
end
|
82
48
|
|
49
|
+
add_conf_checker :mail_conf_checker
|
50
|
+
|
83
51
|
end # class Vcs
|
data/src/message.rb
CHANGED
@@ -30,24 +30,23 @@ class Vcs
|
|
30
30
|
f.puts options.to_yaml
|
31
31
|
f.puts '---'
|
32
32
|
f.puts
|
33
|
-
message.
|
34
|
-
f.print line
|
35
|
-
end
|
33
|
+
f.print message.read
|
36
34
|
end
|
37
35
|
end
|
38
36
|
private :print_body
|
39
37
|
|
40
38
|
def message ( *args )
|
39
|
+
error_handling :message_failed
|
40
|
+
|
41
41
|
unless @@message.exist?
|
42
42
|
cl = mkchangelog(*args)
|
43
43
|
@@message.open('w') do |f|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
diffstat(*args).each { |line| f.print line }
|
44
|
+
f.puts 'Index: ChangeLog'
|
45
|
+
f.print cl.read.sub(/^\d+-\d+-\d+/, 'from')
|
46
|
+
f.puts
|
47
|
+
f.print diffstat(*args).read
|
49
48
|
f.puts
|
50
|
-
|
49
|
+
diffw_from_status(*args).each { |line| f.print line if line !~ /^=+$/ }
|
51
50
|
end
|
52
51
|
end
|
53
52
|
@@message.open('r')
|
@@ -55,4 +54,11 @@ class Vcs
|
|
55
54
|
|
56
55
|
alias_command :msg, :message
|
57
56
|
|
57
|
+
def message_failed
|
58
|
+
if @@message.exist?
|
59
|
+
LOG.info "#{@@message}: Contains the generated message"
|
60
|
+
LOG.info ' (the ChangeLog entry, the diffstat, the diff)'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
58
64
|
end # class Vcs
|
data/src/mycommit.rb
CHANGED
@@ -10,8 +10,10 @@ require 'ask'
|
|
10
10
|
|
11
11
|
class Vcs
|
12
12
|
|
13
|
+
COMMITED = Pathname.new(',commited')
|
14
|
+
|
13
15
|
def edit! ( *files )
|
14
|
-
system(
|
16
|
+
system(EDITOR, *files.map { |x| x.to_s })
|
15
17
|
end
|
16
18
|
|
17
19
|
def common_commit! ( *args, &block )
|
@@ -20,7 +22,7 @@ class Vcs
|
|
20
22
|
|
21
23
|
update!
|
22
24
|
|
23
|
-
unless
|
25
|
+
unless COMMITED.exist?
|
24
26
|
|
25
27
|
begin
|
26
28
|
mkchangelog(*args)
|
@@ -32,44 +34,57 @@ class Vcs
|
|
32
34
|
|
33
35
|
edit! @@message
|
34
36
|
|
35
|
-
|
37
|
+
if ask('Committing, are you sure?', :y) == :n
|
38
|
+
commit_failed
|
39
|
+
end
|
40
|
+
|
41
|
+
concat_changelog!(*args)
|
36
42
|
|
37
43
|
#pager! diff
|
38
44
|
#pager! status
|
39
45
|
|
40
46
|
args << 'ChangeLog' unless args.grep(/^[^-]/).empty?
|
41
47
|
|
42
|
-
if ask('Committing, are you sure?', :y) == :n
|
43
|
-
@@message.unlink
|
44
|
-
LOG.error 'Aborting'
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
|
48
48
|
if commit!('-F', ADD_CL, *(opts + args))
|
49
|
-
|
50
|
-
ADD_CL.delete
|
49
|
+
ADD_CL.rename(COMMITED)
|
51
50
|
TMP_CL.delete if TMP_CL.exist?
|
52
51
|
else
|
53
|
-
|
54
|
-
raise Failure, 'commit failed'
|
52
|
+
commit_failed
|
55
53
|
end
|
56
54
|
|
57
55
|
update!
|
58
56
|
|
57
|
+
else
|
58
|
+
|
59
|
+
message(*args)
|
60
|
+
edit! @@message
|
61
|
+
|
59
62
|
end
|
60
63
|
|
64
|
+
|
61
65
|
rev = self.revision.readline.chomp.to_i
|
62
66
|
|
63
67
|
block.call(rev) if block_given?
|
64
68
|
|
69
|
+
LOG.info 'Deleting junk files...'
|
70
|
+
TMP_CL.delete if TMP_CL.exist?
|
71
|
+
ADD_CL.delete if ADD_CL.exist?
|
72
|
+
COMMITED.delete if COMMITED.exist?
|
65
73
|
messages = Pathname.new(',messages')
|
66
74
|
messages.mkpath unless messages.directory?
|
67
75
|
message_rev = messages + "#{@@message}.#{rev}"
|
68
76
|
LOG.info "Moving `#{@@message}' to `#{message_rev}'..."
|
69
77
|
@@message.rename(message_rev)
|
70
|
-
LOG.info "
|
78
|
+
LOG.info "You can remove `#{message_rev}' if everything is ok."
|
71
79
|
|
72
80
|
end
|
73
81
|
alias_command :cci, :common_commit
|
74
82
|
|
83
|
+
def commit_failed
|
84
|
+
LOG.info "#{COMMITED}: Contains your ChangeLog entry" if COMMITED.exist?
|
85
|
+
LOG.error 'Aborting'
|
86
|
+
LOG.info 'You can rerun the same command to continue the commit'
|
87
|
+
raise 'Commit failed'
|
88
|
+
end
|
89
|
+
|
75
90
|
end # class Vcs
|