svnauto 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -1,9 +1,8 @@
1
1
  = To Do List
2
2
 
3
- == Before Version 1.0.0
4
-
5
- * Create the intro screencast
6
-
7
3
  == Future Versions
8
4
 
5
+ * Add reporting tool to report on things such as what bug fixes
6
+ went into which releases
7
+ * More advanced merging
9
8
  * Support letters in version numbers, like 1.1.1a
data/lib/sc/command.rb CHANGED
@@ -80,6 +80,12 @@ module SC
80
80
  instance_eval { @opthash.clear }
81
81
  end
82
82
 
83
+ ################################################################################
84
+ # Was the --force option given to the command?
85
+ def self.force?
86
+ instance_eval { @opthash[:force] }
87
+ end
88
+
83
89
  ################################################################################
84
90
  protected
85
91
 
@@ -43,6 +43,10 @@ module SC
43
43
  opthash[:close] = true
44
44
  end
45
45
 
46
+ option('-d', '--diff', "Show the changes for the given bug fix") do |val, opthash|
47
+ opthash[:diff] = true
48
+ end
49
+
46
50
  option('-t', '--no-trunk', "Don't merge bug fix to the trunk") do |val, opthash|
47
51
  opthash[:no_trunk] = true
48
52
  end
@@ -56,6 +60,11 @@ module SC
56
60
  raise "bug id should be an integer: #{@bug_id}"
57
61
  end
58
62
 
63
+ if opthash[:diff]
64
+ show_diff
65
+ return
66
+ end
67
+
59
68
  @version =
60
69
  if opthash[:release]
61
70
  Version.new(opthash[:release])
@@ -153,6 +162,11 @@ module SC
153
162
  end
154
163
  end
155
164
  end
165
+
166
+ ################################################################################
167
+ def show_diff
168
+ Svn.diff(@project.tags("bug/PRE-#@bug_id"), @project.tags("bug/POST-#@bug_id"))
169
+ end
156
170
 
157
171
  end
158
172
  ################################################################################
@@ -35,7 +35,7 @@ module SC
35
35
  ################################################################################
36
36
  option('-a', '--add', 'Add a repository') do |val, hash|
37
37
  config = ConfigFile.new
38
- config[:repositories] << Repository.ask
38
+ config[:repositories] << Repository.ask(config)
39
39
  config.save
40
40
  end
41
41
 
data/lib/sc/constants.rb CHANGED
@@ -26,7 +26,7 @@ module SC
26
26
  module Constants
27
27
  ################################################################################
28
28
  # The version number for this copy of SC
29
- VERSION = '1.0.1'
29
+ VERSION = '1.0.2'
30
30
 
31
31
  ################################################################################
32
32
  # What to call myself
data/lib/sc/dispatcher.rb CHANGED
@@ -121,6 +121,13 @@ module SC
121
121
  end
122
122
  end
123
123
 
124
+ # make sure the selected repository is in the config file
125
+ if !klass.without_repository and !config.find_repository(@project.repository.name)
126
+ error = "the selected repository (#{@project.repository.url}) is not in the configuration file, "
127
+ error << "please use the 'sc config --add' command to add it first."
128
+ raise error
129
+ end
130
+
124
131
  process(klass, subcommand_options, @project)
125
132
  end
126
133
 
@@ -151,6 +158,9 @@ module SC
151
158
  command_extras = klass.options.order!(options)
152
159
  return unless klass.instance_methods.include?('run')
153
160
 
161
+ # make sure the project object is ready
162
+ project.prepare(klass.force?)
163
+
154
164
  if klass.args_min and command_extras.length < klass.args_min
155
165
  puts usage_for(klass)
156
166
  exit 1
data/lib/sc/project.rb CHANGED
@@ -72,6 +72,12 @@ module SC
72
72
  @repository = options[:repository]
73
73
  end
74
74
 
75
+ ################################################################################
76
+ # make sure the project is ready to be used
77
+ def prepare (force)
78
+ @repository.prepare(force) if @repository
79
+ end
80
+
75
81
  ################################################################################
76
82
  # get the URL to this project
77
83
  def url
@@ -209,14 +215,19 @@ module SC
209
215
 
210
216
  Dir.chdir(dir) do
211
217
  conflicts = false
212
-
213
- Svn.merge(start_tag, end_tag) do |line|
214
- conflicts = true if line.match(/^\s*C/)
215
- print line
218
+ Svn.merge(start_tag, end_tag)
219
+
220
+ # test to make sure there are no conflicts
221
+ Svn.status do |line|
222
+ if line.match(/^\s*C/)
223
+ conflicts = true
224
+ Constants::TERMINAL.say(Constants::TERMINAL.color("MERGE CONFLICT: #{line.chomp}", :red))
225
+ end
216
226
  end
217
227
 
218
228
  if conflicts
219
229
  message = "merge failed, you need to resolve conflicts in #{dir} "
230
+ message << "(use 'svn status' to see files with conflicts) "
220
231
  message << yield if block_given?
221
232
  raise message
222
233
  end
data/lib/sc/repository.rb CHANGED
@@ -43,11 +43,17 @@ module SC
43
43
 
44
44
  ################################################################################
45
45
  # Prompt the user to enter the necessary attributes for a repository
46
- def self.ask
46
+ def self.ask (config=nil)
47
47
  options = {}
48
48
 
49
49
  options[:name] = Constants::TERMINAL.ask("Repository Name (used with sc -r): ")
50
- options[:url] = Constants::TERMINAL.ask("Repository URL: ")
50
+
51
+ options[:url] = Constants::TERMINAL.ask("Repository URL: ") do |question|
52
+ if config
53
+ project = Project.from_cwd(config)
54
+ question.default = project.repository.url unless project.repository.nil?
55
+ end
56
+ end
51
57
 
52
58
  url = URI.parse(options[:url])
53
59
  if url.scheme.nil? and Constants::TERMINAL.agree("Repository URL is missing protocol, assume it's local? ")
@@ -68,7 +74,9 @@ module SC
68
74
  q.default = default_workspace(options[:name])
69
75
  end
70
76
 
71
- self.new(options)
77
+ repository = self.new(options)
78
+ repository.prepare(false)
79
+ repository
72
80
  end
73
81
 
74
82
  ################################################################################
@@ -91,6 +99,22 @@ module SC
91
99
  @options = options[:options]
92
100
  end
93
101
 
102
+ ################################################################################
103
+ # make sure the repository is ready to use
104
+ def prepare (force)
105
+ workspace_dir = workspace()
106
+
107
+ unless File.exist?(workspace_dir)
108
+ question = "Create workspace "
109
+ question << Constants::TERMINAL.color(workspace_dir, :green)
110
+ question << "? "
111
+
112
+ if force or Constants::TERMINAL.agree(question)
113
+ Pathname.new(workspace_dir).mkpath
114
+ end
115
+ end
116
+ end
117
+
94
118
  ################################################################################
95
119
  # get the full path for the workspace
96
120
  def workspace
data/lib/sc/svn.rb CHANGED
@@ -24,6 +24,11 @@
24
24
  ################################################################################
25
25
  module SC
26
26
  class Svn
27
+ ################################################################################
28
+ # Since we're using regexes, we can only support one language, so we pick
29
+ # English. This setting forces svn to output English.
30
+ ENV['LC_MESSAGES'] = 'C'
31
+
27
32
  ################################################################################
28
33
  # Run a svn subcommand
29
34
  def self._svn (*args)
data/lib/sc.rb CHANGED
@@ -25,6 +25,7 @@
25
25
  require 'rubygems'
26
26
  require 'highline'
27
27
  require 'uri'
28
+ require 'pathname'
28
29
  ################################################################################
29
30
  require 'sc/constants'
30
31
  require 'sc/version'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: svnauto
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2006-11-06 00:00:00 -07:00
6
+ version: 1.0.2
7
+ date: 2006-11-10 00:00:00 -07:00
8
8
  summary: Wrapper around svn for automating complex tasks
9
9
  require_paths:
10
10
  - lib