amikula-conditional_dcommit 0.1.0
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.
- data/LICENSE +20 -0
- data/README.rdoc +10 -0
- data/Rakefile +41 -0
- data/VERSION.yml +4 -0
- data/bin/conditional_dcommit +4 -0
- data/data/growlNotify.applescript +35 -0
- data/data/stop_sign.jpg +0 -0
- data/data/traffic_green.jpg +0 -0
- data/lib/conditional_dcommit.rb +2 -0
- data/lib/conditional_dcommit/command.rb +99 -0
- data/lib/conditional_dcommit/package.rb +11 -0
- data/spec/conditional_dcommit/command_spec.rb +62 -0
- data/spec/conditional_dcommit/package_spec.rb +21 -0
- data/spec/conditional_dcommit_spec.rb +5 -0
- data/spec/spec_helper.rb +9 -0
- metadata +71 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Alf Mikula
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
= conditional_dcommit
|
2
|
+
|
3
|
+
A command for running your commit tests, rebasing, rerunning if necessary, and dcommitting once everything is all good.
|
4
|
+
|
5
|
+
== Copyright
|
6
|
+
|
7
|
+
Copyright (c) 2009 Alf Mikula. See LICENSE for details.
|
8
|
+
growlNotify.applescript redistributed with permission from Mike Hagedorn.
|
9
|
+
Traffic light image provided by Believe Collective (http://www.flickr.com/photos/chainedreactions/)
|
10
|
+
Stop sign image provided by ladybeames (http://www.flickr.com/photos/50906336@N00/)
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "conditional_dcommit"
|
8
|
+
gem.summary = %Q{Loops through rebase and test until tests pass and there are no new changes in the repository, then issues a git svn dcommit.}
|
9
|
+
gem.email = "amikula@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/amikula/conditional_dcommit"
|
11
|
+
gem.authors = ["Alf Mikula"]
|
12
|
+
gem.files.concat(FileList['data/**/*'])
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/rdoctask'
|
20
|
+
Rake::RDocTask.new do |rdoc|
|
21
|
+
rdoc.rdoc_dir = 'rdoc'
|
22
|
+
rdoc.title = 'conditional_dcommit'
|
23
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
24
|
+
rdoc.rdoc_files.include('README*')
|
25
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'spec/rake/spectask'
|
29
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
35
|
+
spec.libs << 'lib' << 'spec'
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
task :default => :spec
|
data/VERSION.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
-- growlNotify.applescript
|
2
|
+
--
|
3
|
+
-- Created by Mike Hagedorn on 2007-10-31.
|
4
|
+
-- Copyright (c) 2007 Silverchair Solutions. All rights reserved. http://www.silverchairsolutions.com
|
5
|
+
-- based on script from the growl website
|
6
|
+
-- works around the fact that growlnotify doesnt work on leopard
|
7
|
+
|
8
|
+
-- pass in like osascript growlNotify.applescript
|
9
|
+
on run argv
|
10
|
+
set rspectitle to item 1 of argv
|
11
|
+
set rspecmessage to item 2 of argv
|
12
|
+
set rspecimage to item 3 of argv
|
13
|
+
set rspecsticky to item 4 of argv
|
14
|
+
|
15
|
+
tell application "GrowlHelperApp"
|
16
|
+
-- Make a list of all the notification types
|
17
|
+
-- that this script will ever send:
|
18
|
+
set the allNotificationsList to {"RSpec Notification"}
|
19
|
+
|
20
|
+
-- Make a list of the notifications
|
21
|
+
-- that will be enabled by default.
|
22
|
+
-- Those not enabled by default can be enabled later
|
23
|
+
-- in the 'Applications' tab of the growl prefpane.
|
24
|
+
set the enabledNotificationsList to {"RSpec Notification"}
|
25
|
+
|
26
|
+
-- Register our script with growl.
|
27
|
+
-- You can optionally (as here) set a default icon
|
28
|
+
-- for this script's notifications.
|
29
|
+
register as application "Growl-RSpec AppleScript Notifications" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
|
30
|
+
|
31
|
+
-- Send a Notification...
|
32
|
+
notify with name "RSpec Notification" title rspectitle description rspecmessage application name "Growl-RSpec AppleScript Notifications" image from location rspecimage sticky rspecsticky
|
33
|
+
end tell
|
34
|
+
|
35
|
+
end run
|
data/data/stop_sign.jpg
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'open4'
|
5
|
+
|
6
|
+
require 'conditional_dcommit/package'
|
7
|
+
|
8
|
+
module ConditionalDcommit
|
9
|
+
class Command
|
10
|
+
attr_accessor :status_code
|
11
|
+
|
12
|
+
def test_command
|
13
|
+
@test_command ||= ENV['TEST_COMMAND'] || 'script/cruise'
|
14
|
+
end
|
15
|
+
|
16
|
+
def code_tests_ok?
|
17
|
+
puts "testing code"
|
18
|
+
system(test_command) ? true : false
|
19
|
+
end
|
20
|
+
|
21
|
+
def dcommit
|
22
|
+
puts "dcommitting"
|
23
|
+
system("git svn dcommit") ? true : false
|
24
|
+
end
|
25
|
+
|
26
|
+
def rebase
|
27
|
+
puts "rebasing"
|
28
|
+
pid, stdin, stdout, stderr = Open4.popen4('git svn rebase')
|
29
|
+
firstline = nil
|
30
|
+
|
31
|
+
until (firstline = stdout.gets) || (firsterror = stderr.gets)
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "firstline: #{firstline}"
|
35
|
+
puts "firsterror: #{firsterror}"
|
36
|
+
|
37
|
+
if firsterror && firsterror.chomp =~ /Current branch .* is up to date./
|
38
|
+
retval = false
|
39
|
+
else
|
40
|
+
puts firstline || firsterror
|
41
|
+
|
42
|
+
while line = stdout.gets || stderr.gets
|
43
|
+
puts line
|
44
|
+
end
|
45
|
+
retval = true
|
46
|
+
end
|
47
|
+
|
48
|
+
ignored, status = Process::waitpid2 pid
|
49
|
+
|
50
|
+
raise StandardError.new("Error rebasing") if status != 0
|
51
|
+
|
52
|
+
puts "rebase return: #{retval.to_s}"
|
53
|
+
|
54
|
+
retval
|
55
|
+
end
|
56
|
+
|
57
|
+
def report_fail(message="Failed dcommit")
|
58
|
+
puts message
|
59
|
+
self.status_code = 255
|
60
|
+
growl('FAIL', message, Package.data_file('stop_sign.jpg'))
|
61
|
+
end
|
62
|
+
|
63
|
+
def report_success(message="Successful dcommit")
|
64
|
+
puts message
|
65
|
+
self.status_code = 0
|
66
|
+
growl('Success', message, Package.data_file('traffic_green.jpg'))
|
67
|
+
end
|
68
|
+
|
69
|
+
def growl(title, message, image, stick="yes")
|
70
|
+
growlNotify_file = Package.data_file('growlNotify.applescript')
|
71
|
+
|
72
|
+
system "osascript #{growlNotify_file} '#{title}' '#{message}' '#{image}' #{stick}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def main
|
76
|
+
self.status_code = 254
|
77
|
+
|
78
|
+
begin
|
79
|
+
rebase
|
80
|
+
|
81
|
+
5.times do
|
82
|
+
if code_tests_ok?
|
83
|
+
unless rebase
|
84
|
+
raise StandardError.new("Error dcommitting") unless dcommit
|
85
|
+
report_success
|
86
|
+
break
|
87
|
+
end
|
88
|
+
else
|
89
|
+
raise StandardError.new("Code tests failed")
|
90
|
+
end
|
91
|
+
end && report_fail("Too many tries")
|
92
|
+
rescue StandardError => err
|
93
|
+
report_fail(err.to_s)
|
94
|
+
end
|
95
|
+
|
96
|
+
self.status_code
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
require 'conditional_dcommit/command'
|
4
|
+
|
5
|
+
describe ConditionalDcommit::Command do
|
6
|
+
def subject
|
7
|
+
@subject ||= ConditionalDcommit::Command.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe :test_command do
|
11
|
+
it "returns the environment variable 'TEST_COMMAND'" do
|
12
|
+
ENV.should_receive(:[]).with('TEST_COMMAND').and_return("test command")
|
13
|
+
|
14
|
+
subject.test_command.should == 'test command'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "defaults to 'script/cruise'" do
|
18
|
+
ENV.should_receive(:[]).and_return(nil)
|
19
|
+
|
20
|
+
subject.test_command.should == 'script/cruise'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "caches the test_command value" do
|
24
|
+
ENV.should_receive(:[]).exactly(1).times.with('TEST_COMMAND').and_return(nil)
|
25
|
+
|
26
|
+
subject.test_command.should == 'script/cruise'
|
27
|
+
subject.test_command.should == 'script/cruise'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe :report_fail do
|
32
|
+
before(:each) do
|
33
|
+
subject.stub!(:puts)
|
34
|
+
subject.stub!(:growl)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'outputs the failure message to the console' do
|
38
|
+
subject.should_receive(:puts).with(:message)
|
39
|
+
|
40
|
+
subject.report_fail(:message)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "sets status code to 255" do
|
44
|
+
subject.report_fail(:anything)
|
45
|
+
|
46
|
+
subject.status_code.should == 255
|
47
|
+
end
|
48
|
+
|
49
|
+
it "growls the message" do
|
50
|
+
subject.should_receive(:growl).with('FAIL', :message, anything)
|
51
|
+
|
52
|
+
subject.report_fail(:message)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "growls with the failure image" do
|
56
|
+
ConditionalDcommit::Package.should_receive(:data_file).with('stop_sign.jpg').and_return(:stop_sign_file)
|
57
|
+
subject.should_receive(:growl).with('FAIL', anything, :stop_sign_file)
|
58
|
+
|
59
|
+
subject.report_fail(:message)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
require 'conditional_dcommit/package'
|
4
|
+
|
5
|
+
describe ConditionalDcommit::Package do
|
6
|
+
def subject
|
7
|
+
ConditionalDcommit::Package
|
8
|
+
end
|
9
|
+
|
10
|
+
describe :data_path do
|
11
|
+
it "should point to a directory containing data I care about" do
|
12
|
+
File.file?(File.join(subject.data_path, 'stop_sign.jpg')).should be_true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :data_file do
|
17
|
+
it "should return a path starting with data_path and ending with the data file specified" do
|
18
|
+
subject.data_file('foo').should == File.join(subject.data_path, 'foo')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amikula-conditional_dcommit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alf Mikula
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-30 00:00:00 -07:00
|
13
|
+
default_executable: conditional_dcommit
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: amikula@gmail.com
|
18
|
+
executables:
|
19
|
+
- conditional_dcommit
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- LICENSE
|
27
|
+
- README.rdoc
|
28
|
+
- Rakefile
|
29
|
+
- VERSION.yml
|
30
|
+
- bin/conditional_dcommit
|
31
|
+
- data/growlNotify.applescript
|
32
|
+
- data/stop_sign.jpg
|
33
|
+
- data/traffic_green.jpg
|
34
|
+
- lib/conditional_dcommit.rb
|
35
|
+
- lib/conditional_dcommit/command.rb
|
36
|
+
- lib/conditional_dcommit/package.rb
|
37
|
+
- spec/conditional_dcommit/command_spec.rb
|
38
|
+
- spec/conditional_dcommit/package_spec.rb
|
39
|
+
- spec/conditional_dcommit_spec.rb
|
40
|
+
- spec/spec_helper.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/amikula/conditional_dcommit
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.2.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Loops through rebase and test until tests pass and there are no new changes in the repository, then issues a git svn dcommit.
|
67
|
+
test_files:
|
68
|
+
- spec/conditional_dcommit/command_spec.rb
|
69
|
+
- spec/conditional_dcommit/package_spec.rb
|
70
|
+
- spec/conditional_dcommit_spec.rb
|
71
|
+
- spec/spec_helper.rb
|