propel 0.4.1 → 0.4.2
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/lib/propel/git_repository.rb +18 -3
- data/lib/propel/runner.rb +2 -0
- data/lib/propel/version.rb +1 -1
- data/spec/propel/git_repository_spec.rb +37 -0
- data/spec/propel/runner_spec.rb +14 -0
- metadata +4 -4
@@ -20,6 +20,10 @@ module Propel
|
|
20
20
|
local_last_commit != remote_last_commit
|
21
21
|
end
|
22
22
|
|
23
|
+
def ensure_attached_head!
|
24
|
+
exit_with_error('You are operating with a detached HEAD, aborting.') if current_branch == '(no branch)'
|
25
|
+
end
|
26
|
+
|
23
27
|
def pull(rebase)
|
24
28
|
pull_cmd = 'pull'
|
25
29
|
pull_cmd << ' --rebase' if rebase
|
@@ -76,8 +80,20 @@ module Propel
|
|
76
80
|
end
|
77
81
|
|
78
82
|
def git git_args
|
79
|
-
output =
|
80
|
-
|
83
|
+
output, exitcode = run_command(git_args)
|
84
|
+
|
85
|
+
if exitcode == 0
|
86
|
+
Result.new(output, exitcode)
|
87
|
+
|
88
|
+
else
|
89
|
+
puts output
|
90
|
+
exit exitcode
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def run_command(cmd)
|
95
|
+
output = `git #{cmd}`.strip
|
96
|
+
[ output, $?.exitstatus ]
|
81
97
|
end
|
82
98
|
|
83
99
|
def local_last_commit
|
@@ -90,7 +106,6 @@ module Propel
|
|
90
106
|
end
|
91
107
|
|
92
108
|
def current_branch
|
93
|
-
# TODO - replace with git symbolic-ref HEAD
|
94
109
|
git("branch").result.split("\n").detect{|l| l =~ /^\*/ }.gsub(/^\* /, '')
|
95
110
|
end
|
96
111
|
|
data/lib/propel/runner.rb
CHANGED
data/lib/propel/version.rb
CHANGED
@@ -5,14 +5,51 @@ describe Propel::GitRepository do
|
|
5
5
|
it "should use --rebase when argument is true" do
|
6
6
|
git_repository = Propel::GitRepository.new
|
7
7
|
git_repository.should_receive(:git).with("pull --rebase")
|
8
|
+
|
8
9
|
git_repository.pull(true)
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should not use --rebase when argument as false" do
|
12
13
|
git_repository = Propel::GitRepository.new
|
14
|
+
|
13
15
|
git_repository.should_receive(:git).with("pull")
|
14
16
|
git_repository.pull(false)
|
15
17
|
end
|
18
|
+
|
19
|
+
describe "when the process exits with a non-zero exit status" do
|
20
|
+
it "should print the process stdout to the console and exit with the exit code of the process" do
|
21
|
+
git_repository = Propel::GitRepository.new
|
22
|
+
|
23
|
+
git_repository.should_receive(:run_command).with('pull --rebase').and_return([ 'my message', 127 ])
|
24
|
+
git_repository.should_receive(:exit).with(127)
|
25
|
+
git_repository.should_receive(:puts).with('my message')
|
26
|
+
git_repository.pull(true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#ensure_attached_head!" do
|
32
|
+
class DetachedHeadTrap < StandardError ; end
|
33
|
+
|
34
|
+
it "should warn the user and exit with a status of 1 when the head is detached" do
|
35
|
+
git_repository = Propel::GitRepository.new
|
36
|
+
git_repository.stub!(:current_branch).and_return('(no branch)')
|
37
|
+
git_repository.should_receive(:exit_with_error).with('You are operating with a detached HEAD, aborting.').and_raise(DetachedHeadTrap)
|
38
|
+
|
39
|
+
lambda {
|
40
|
+
git_repository.ensure_attached_head!
|
41
|
+
}.should raise_error(DetachedHeadTrap)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not exit when on master branch" do
|
45
|
+
git_repository = Propel::GitRepository.new
|
46
|
+
git_repository.stub!(:current_branch).and_return('master')
|
47
|
+
git_repository.should_not_receive(:exit_with_error)
|
48
|
+
|
49
|
+
lambda {
|
50
|
+
git_repository.ensure_attached_head!
|
51
|
+
}.should_not raise_error(DetachedHeadTrap)
|
52
|
+
end
|
16
53
|
end
|
17
54
|
|
18
55
|
describe "#push" do
|
data/spec/propel/runner_spec.rb
CHANGED
@@ -8,6 +8,20 @@ describe Propel::Runner do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe ".start" do
|
11
|
+
class DetachedHeadTrap < StandardError ; end
|
12
|
+
|
13
|
+
it "should not call propel! if HEAD is detached" do
|
14
|
+
runner = Propel::Runner.new
|
15
|
+
runner.stub!(:logger).and_return(stub_logger)
|
16
|
+
@git_repository.stub!(:ensure_attached_head!).and_raise(DetachedHeadTrap)
|
17
|
+
|
18
|
+
runner.should_not_receive(:propel!)
|
19
|
+
|
20
|
+
lambda {
|
21
|
+
runner.start
|
22
|
+
}.should raise_error(DetachedHeadTrap)
|
23
|
+
end
|
24
|
+
|
11
25
|
it "should not call propel! if there is nothing to push" do
|
12
26
|
runner = Propel::Runner.new
|
13
27
|
runner.stub!(:logger).and_return(stub_logger)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Leitgeb
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|