shipit 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/ChangeLog +13 -3
  2. data/Rakefile +1 -6
  3. data/lib/shipit/vc.rb +135 -0
  4. data/lib/shipit.rb +15 -23
  5. metadata +6 -4
data/ChangeLog CHANGED
@@ -1,4 +1,16 @@
1
- ChangeLog of http://svn.coderepos.org/share/lang/ruby/shipit/trunk
1
+ 2008-06-14 cho45
2
+
3
+ * [new]:
4
+ Supported git.
5
+
6
+ * [release]:
7
+ Release 0.0.7
8
+
9
+ 2008-01-29 cho45
10
+
11
+ * [release]:
12
+ Release 0.0.6
13
+
2
14
 
3
15
  2008-01-19 cho45
4
16
 
@@ -11,8 +23,6 @@ ChangeLog of http://svn.coderepos.org/share/lang/ruby/shipit/trunk
11
23
  * [bug][interface] @4959:
12
24
  Remove 3rd argument of Step::ChangeVersion because it is meaningless.
13
25
  Fix bug around checking vers on Step::ChangeVersion.
14
-
15
-
16
26
 
17
27
  * [new] @4958:
18
28
  Implement checking VERS constant to avoid trap.
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ DESCRIPTION = "Automated release tasks."
19
19
  RUBYFORGE_PROJECT = "lowreal"
20
20
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
21
21
  BIN_FILES = %w( )
22
- VERS = "0.0.6"
22
+ VERS = "0.0.7"
23
23
 
24
24
  REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
25
25
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
@@ -116,11 +116,6 @@ Rake::ShipitTask.new do |s|
116
116
  s.Step.new {
117
117
  system("svn", "up")
118
118
  }.and {}
119
- s.Step.new {
120
- raise "changelog-with-hatenastar.rb is not found" unless system("which", "changelog-with-hatenastar.rb")
121
- }.and {
122
- system("changelog-with-hatenastar.rb > ChangeLog")
123
- }
124
119
  s.Task :rubyforge
125
120
  s.ChangeVersion "Rakefile", "VERS"
126
121
  s.Commit
data/lib/shipit/vc.rb ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require "shipit"
5
+ require "tempfile"
6
+
7
+ module Rake::ShipitTask::VC
8
+ def self.new
9
+ constants.map {|c| const_get(c) }.find {|c|
10
+ c.accept?
11
+ }.new
12
+ end
13
+
14
+ class Git
15
+ def self.accept?
16
+ File.exist? ".git"
17
+ end
18
+
19
+ def commit(msg)
20
+ temp = Tempfile.open("COMMIT_MESSAGE")
21
+ temp << msg
22
+ temp.close
23
+
24
+ system "git", "commit", "-a", "-F", temp.path
25
+ end
26
+
27
+ def precommit
28
+ unknown = `git ls-files -z --others --exclude-per-directory=.gitignore --exclude-from=.git/info/exclude`
29
+ if unknown.gsub!(/\0/, "\n")
30
+ raise unknown
31
+ end
32
+ end
33
+
34
+ def exists_tagged_version(ver)
35
+ !`git tag -l #{ver}`.empty?
36
+ end
37
+
38
+
39
+ def tag_version(ver, msg=nil)
40
+ msg = "Tagging version #{ver}." unless msg
41
+
42
+ temp = Tempfile.open("COMMIT_MESSAGE")
43
+ temp << msg
44
+ temp.close
45
+
46
+ tag = ver
47
+
48
+ system "git", "tag", "-a", "-F", temp.path, tag
49
+ end
50
+
51
+ def local_diff(file)
52
+ `git diff --no-color HEAD '#{file}'`
53
+ end
54
+
55
+ def are_local_diffs(ver)
56
+ `git diff --no-color #{ver}`.match(/\S/)
57
+ end
58
+ end
59
+
60
+ class SVN
61
+ def self.accept?
62
+ File.exist? ".svn"
63
+ end
64
+
65
+ def commit(msg)
66
+ temp = Tempfile.open("svn-commit")
67
+ temp << msg
68
+ temp.close
69
+
70
+ system "svn", "ci", "--file", temp.path
71
+ end
72
+
73
+ def precommit
74
+ unknown = []
75
+ changes = false
76
+ `svn st`.split(/\n/).each do |l|
77
+ changes = true
78
+ next unless l =~ /^\?/
79
+ unknown << l
80
+ end
81
+
82
+ unless unknown.empty?
83
+ raise unknown.join("\n")
84
+ end
85
+
86
+ unless changes
87
+ warn "No locally changed files. skipping commit"
88
+ return
89
+ end
90
+ end
91
+
92
+ def exists_tagged_version(ver)
93
+ !!`svn info '#{tag_url(ver)}'`[/Node Kind: directory/]
94
+ end
95
+
96
+ def tag_version(ver, msg)
97
+ temp = Tempfile.open("svn-commit")
98
+ temp << msg
99
+ temp.close
100
+
101
+ system 'svn', 'copy', '--file', temp.path, trunk_url.to_s, tag_url(ver).to_s
102
+ end
103
+
104
+ def local_diff(file)
105
+ `svn diff #{file}`
106
+ end
107
+
108
+ def are_local_diffs(ver)
109
+ `svn diff`.match(/\S/)
110
+ end
111
+
112
+ private
113
+ def tag_url(ver)
114
+ require "uri"
115
+ ENV["LANG"] = "C"
116
+ url = `svn info`[/^URL: (.+)/, 1]
117
+ @url = trunk_url + "."
118
+ unless `svn info '#{(@url + "tags")}'`[/Node Kind: directory/]
119
+ raise "tags directory is not found"
120
+ end
121
+ @url + "tags/#{ver}"
122
+ end
123
+
124
+ def trunk_url
125
+ url = `svn info`[/^URL: (.+)/, 1]
126
+ if url =~ /trunk$/
127
+ URI(url)
128
+ else
129
+ raise "Run at trunk! Here is #{url}"
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+
data/lib/shipit.rb CHANGED
@@ -1,3 +1,6 @@
1
+
2
+ $LOAD_PATH.unshift "lib"
3
+
1
4
  require "rubygems"
2
5
  require "rake"
3
6
  require "rake/tasklib"
@@ -5,6 +8,8 @@ require "term/ansicolor"
5
8
  require "fileutils"
6
9
 
7
10
  class Rake::ShipitTask < Rake::TaskLib
11
+ require "shipit/vc"
12
+
8
13
  attr_reader :name
9
14
  attr_reader :steps
10
15
 
@@ -172,17 +177,13 @@ class Rake::ShipitTask::Step::Commit
172
177
  end
173
178
 
174
179
  def prepare
180
+ @vc = Rake::ShipitTask::VC.new
175
181
  @vers = VERS
176
- st = `svn st`
177
- unless st.empty?
178
- puts "Any changes remain?"
179
- puts st
180
- exit
181
- end
182
+ @vc.precommit
182
183
  end
183
184
 
184
185
  def run
185
- system "svn", "ci", "-m", @msg || "Release #{@vers}"
186
+ @vc.commit(@msg || "Release #{@vers}")
186
187
  end
187
188
  end
188
189
 
@@ -192,26 +193,16 @@ class Rake::ShipitTask::Step::Tag
192
193
  end
193
194
 
194
195
  def prepare
195
- require "uri"
196
- ENV["LANG"] = "C"
197
- url = `svn info`[/^URL: (.+)/, 1]
198
- if url =~ /trunk$/
199
- @url = URI(url) + "."
200
- unless `svn info '#{(@url + "tags")}'`[/Node Kind: directory/]
201
- raise "tags directory is not found"
202
- end
203
- else
204
- raise "Run at trunk! Here is #{url}"
205
- end
196
+ @vc = Rake::ShipitTask::VC.new
206
197
  @vers = VERS
198
+ @msg = "Release %s" % @vers
199
+ if @vc.exists_tagged_version(@vers)
200
+ raise "#{@tag} is already exists"
201
+ end
207
202
  end
208
203
 
209
204
  def run
210
- trunk = @url + "trunk"
211
- tag = @url + ("tags/#{@format}" % @vers)
212
- msg = "Release %s" % @vers
213
- command = ["svn", "cp", "-m", msg, trunk, tag].map {|i| i.to_s }
214
- system(*command)
205
+ @vc.tag_version(@vers, @msg)
215
206
  end
216
207
  end
217
208
 
@@ -247,6 +238,7 @@ class Rake::ShipitTask::Step::RubyForge
247
238
  def prepare
248
239
  require 'rubyforge'
249
240
  @rf = RubyForge.new
241
+ @rf.configure {}
250
242
  puts "Logging in"
251
243
  @rf.login
252
244
  @c = @rf.userconfig
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - cho45
@@ -9,7 +9,7 @@ autorequire: shipit
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-29 00:00:00 +09:00
12
+ date: 2008-06-14 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,9 +43,11 @@ files:
43
43
  - README
44
44
  - ChangeLog
45
45
  - Rakefile
46
- - test/shipit_test.rb
47
46
  - test/test_helper.rb
47
+ - test/shipit_test.rb
48
48
  - lib/shipit.rb
49
+ - lib/shipit
50
+ - lib/shipit/vc.rb
49
51
  has_rdoc: true
50
52
  homepage: http://lowreal.rubyforge.org
51
53
  post_install_message:
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
81
  requirements: []
80
82
 
81
83
  rubyforge_project: lowreal
82
- rubygems_version: 1.0.1
84
+ rubygems_version: 1.1.1
83
85
  signing_key:
84
86
  specification_version: 2
85
87
  summary: Automated release tasks.