visionmedia-release 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/History.rdoc +15 -0
  2. data/Rakefile +1 -0
  3. data/Todo.rdoc +3 -1
  4. data/bin/re +94 -14
  5. data/release.gemspec +1 -1
  6. metadata +1 -1
data/History.rdoc CHANGED
@@ -1,4 +1,19 @@
1
1
 
2
+ === 0.1.0 / 2009-03-05
3
+
4
+ * Added dependency of visionmedia-commander gem
5
+ * Trapping INT for better abort message
6
+
7
+ === 0.0.8 / 2009-03-05
8
+
9
+ * Better formatting for `re config show`
10
+
11
+ === 0.0.7 / 2009-03-05
12
+
13
+ * Added config sub-command for storing, removing, and viewing configurations
14
+ * Added --config NAME switch to bump sub-command
15
+ * Fixed git log switch preventing --pretty=oneline from working
16
+
2
17
  === 0.0.5 / 2009-03-05
3
18
 
4
19
  * Added git log pretty=oneline to take a look at commits while editing history
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ Echoe.new("release", program(:version)) do |p|
10
10
  p.summary = "Github release management system"
11
11
  p.url = "http://github.com/visionmedia/release"
12
12
  p.runtime_dependencies = []
13
+ p.runtime_dependencies << "visionmedia-commander >=2.4.6"
13
14
  end
14
15
 
15
16
  Dir['tasks/**/*.rake'].sort.each { |f| load f }
data/Todo.rdoc CHANGED
@@ -1,8 +1,10 @@
1
1
 
2
2
  == Major:
3
3
 
4
+ * Ability to abort
5
+ * Get git log working
6
+ * Refactor
4
7
  * Better specs
5
- * Datastore for config at ~/.re/config.yml
6
8
  * When exception is raised revert all alterations made to that point
7
9
 
8
10
  == Minor:
data/bin/re CHANGED
@@ -2,11 +2,18 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'commander'
5
+ require 'yaml'
5
6
 
6
7
  program :name, 'release'
7
- program :version, '0.0.5'
8
+ program :version, '0.1.0'
8
9
  program :description, 'Github release management'
9
10
 
11
+ CONFIG_FILE = File.expand_path('~/.re-config')
12
+
13
+ trap 'INT' do
14
+ raise "release interrupted"
15
+ end
16
+
10
17
  def sh command
11
18
  system command
12
19
  end
@@ -30,9 +37,7 @@ def replace_version file, level
30
37
  version = bump_version(file, level).join '.'
31
38
  contents = File.read file
32
39
  contents.sub! /\d+\.\d+\.\d+/, version
33
- File.open(file, 'w+') do |file|
34
- file.write contents
35
- end
40
+ File.open(file, 'w+') { |f| f.write contents }
36
41
  version
37
42
  end
38
43
 
@@ -44,12 +49,7 @@ def locate_history_file
44
49
  Dir['*'].grep(/history|change/i).first
45
50
  end
46
51
 
47
- command :bump do |c|
48
- c.syntax = 're bump [level] [options]'
49
- c.summary = 'Bump the version <level>, defaults to patch.'
50
- c.description = 'Bump the version by major, minor, or patch (tiny) levels, defaults to patch.'
51
- c.example 'Bump patch level, running several rake tasks first', 're bump --rake manifest,gemspec'
52
- c.example 'Custom message, VERSION replaced with actual version', 're bump major --message \'Release of App VERSION\''
52
+ def bump_options c
53
53
  c.option '-f', '--file FILE', 'File containing the version, otherwise searches lib/ for version.rb'
54
54
  c.option '-m', '--message MESSAGE', String, 'Message defaults to \'- Release VERSION\''
55
55
  c.option '-r', '--rake TASKS', Array, 'Defaults to manifest,gemspec to build manifest / gemspec before releasing'
@@ -57,6 +57,40 @@ command :bump do |c|
57
57
  c.option '-h', '--history', 'Edit history in EDITOR before releasing'
58
58
  c.option '-d', '--dry-run', 'Performs a dry run, without releasing'
59
59
  c.option '-t', '--trace', 'Output callstack when an exception is raised'
60
+ end
61
+
62
+ def save_config config
63
+ File.open(CONFIG_FILE, 'w+') { |f| YAML.dump config, f }
64
+ end
65
+
66
+ def remove_config name
67
+ config = load_config
68
+ config.delete name
69
+ save_config config
70
+ end
71
+
72
+ def load_config name = nil
73
+ raise "configuration file cannot be found, run `re help config` for usage" unless File.exists? CONFIG_FILE
74
+ config = YAML.load_file CONFIG_FILE
75
+ return config unless name
76
+ raise "configuration '#{name}' cannot be found" unless config.include? name
77
+ config[name]
78
+ end
79
+
80
+ def merge_options options, other_options
81
+ a = options.instance_variable_get :"@table"
82
+ b = other_options.instance_variable_get :"@table"
83
+ a.merge! b
84
+ end
85
+
86
+ command :bump do |c|
87
+ bump_options c
88
+ c.syntax = 're bump [level] [options]'
89
+ c.summary = 'Bump the version <level>, defaults to patch'
90
+ c.description = 'Bump the version by major, minor, or patch (tiny) levels, defaults to patch.'
91
+ c.example 'Bump patch level, running several rake tasks first', 're bump --rake manifest,gemspec'
92
+ c.example 'Custom message, VERSION replaced with actual version', 're bump major --message \'Release of App VERSION\''
93
+ c.option '-c', '--config NAME', 'Load configuration options'
60
94
  c.when_called do |args, o|
61
95
  begin
62
96
  # Defaults
@@ -64,7 +98,13 @@ command :bump do |c|
64
98
  o.rake = o.rake || %w( manifest gemspec )
65
99
  o.file = o.file || locate_version_file
66
100
  o.message = o.message || '- Release VERSION'
67
-
101
+
102
+ # Configurations
103
+ if o.config
104
+ say "... using '#{o.config}' configuration"
105
+ merge_options o, load_config(o.config)
106
+ end
107
+
68
108
  # Dry-run
69
109
  if o.dry_run
70
110
  puts "... performing dry-run"
@@ -78,7 +118,7 @@ command :bump do |c|
78
118
 
79
119
  # History
80
120
  if o.history
81
- sh "git log pretty=online"
121
+ sh "git log --pretty=oneline"
82
122
  sh "$EDITOR #{locate_history_file} --wait"
83
123
  end
84
124
 
@@ -89,7 +129,47 @@ command :bump do |c|
89
129
  sh "git tag #{version} && git push && git push --tags"
90
130
  say "... release #{version} complete"
91
131
  rescue Exception => e
92
- o.trace ? raise : say("... release failed: #{e}")
132
+ o.trace ? raise : say("... release failed: #{e}\n")
93
133
  end
94
134
  end
95
- end
135
+ end
136
+
137
+ command :config do |c|
138
+ bump_options c
139
+ c.syntax = 're config <op> <name>'
140
+ c.summary = 'Manage configurations'
141
+ c.description = "Add, remove, or show release configurations."
142
+ c.example 'Create config for myproject. All switches in this command will be stored as the new configuration.',
143
+ 're config add myproject --message "Release myproject VERSION" --file bin/myproject'
144
+ c.example 'Use the config created above', 're bump --config myproject'
145
+ c.example 'Remove myproject config', 're config remove myproject'
146
+ c.example 'Show all configurations', 're show'
147
+ c.when_called do |args, options|
148
+ op = args.shift
149
+ name = args.shift
150
+
151
+ case op
152
+ when 'add'
153
+ raise 'invalid configuration name' unless name
154
+ if File.exists? CONFIG_FILE
155
+ config = load_config
156
+ config[name] = options
157
+ else
158
+ config = { name => options }
159
+ end
160
+ save_config config
161
+ say "... configuration '#{name}' saved"
162
+ when 'remove'
163
+ raise 'invalid configuration name' unless name
164
+ remove_config name
165
+ say "... configuration '#{name}' removed"
166
+ when 'show'
167
+ load_config.each do |name, config|
168
+ say '%14s: %s' % [name, config.inspect.sub('#<OpenStruct ', '').sub('>', '')]
169
+ end
170
+ else
171
+ raise 'invalid operation'
172
+ end
173
+
174
+ end
175
+ end
data/release.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{release}
5
- s.version = "0.0.5"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk