bard 0.5.8 → 0.6.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/VERSION +1 -1
- data/bard.gemspec +2 -1
- data/features/bard_deploy.feature +17 -0
- data/features/step_definitions/git_steps.rb +10 -0
- data/lib/bard.rb +37 -19
- data/lib/bard/git.rb +5 -5
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
data/bard.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bard}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Micah Geisel", "Nick Hogle"]
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"bard.gemspec",
|
30
30
|
"bin/bard",
|
31
31
|
"features/bard_check.feature",
|
32
|
+
"features/bard_deploy.feature",
|
32
33
|
"features/bard_pull.feature",
|
33
34
|
"features/bard_push.feature",
|
34
35
|
"features/step_definitions/check_steps.rb",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Bard deploy should fold the integration branch into master and perform a deploy
|
2
|
+
|
3
|
+
Scenario: Bard deploy detects non-fast-forward merge from integration to master
|
4
|
+
Given a shared rails project
|
5
|
+
And the remote master branch has had a commit since I last pulled
|
6
|
+
And I have committed a set of changes to my local integration branch
|
7
|
+
When I type "bard deploy"
|
8
|
+
Then I should see the fatal error "rebase"
|
9
|
+
|
10
|
+
Scenario: Bard deploy works
|
11
|
+
Given a shared rails project
|
12
|
+
And I have committed a set of changes to my local integration branch
|
13
|
+
When I type "bard deploy"
|
14
|
+
Then the "master" branch should match the "integration" branch
|
15
|
+
And the "integration" branch should match the "origin/integration" branch
|
16
|
+
And the "origin/master" branch should match the "origin/integration" branch
|
17
|
+
|
@@ -29,6 +29,16 @@ Given /^I have committed a set of changes to my local integration branch$/ do
|
|
29
29
|
type "git commit -am'test commit to local integration branch.'"
|
30
30
|
end
|
31
31
|
|
32
|
+
Given /^the remote master branch has had a commit since I last pulled$/ do
|
33
|
+
Dir.chdir "#{ROOT}/tmp/origin" do
|
34
|
+
type "git checkout master"
|
35
|
+
type "echo 'zomg' > origin_master_change_file"
|
36
|
+
type "git add ."
|
37
|
+
type "git commit -am 'testing origin master change'"
|
38
|
+
type "git checkout integration"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
Given /^the remote integration branch has had a commit since I last pulled$/ do
|
33
43
|
Dir.chdir "#{ROOT}/tmp/origin" do
|
34
44
|
type "git checkout integration"
|
data/lib/bard.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
$:.unshift File.expand_path(File.dirname(__FILE__))
|
2
2
|
require 'term/ansicolor'
|
3
|
+
require 'net/http'
|
3
4
|
require 'systemu'
|
4
5
|
require 'grit'
|
5
6
|
require 'thor'
|
@@ -16,7 +17,7 @@ class Bard < Thor
|
|
16
17
|
return check_project(project) if project
|
17
18
|
|
18
19
|
required = {
|
19
|
-
'bard' =>
|
20
|
+
'bard' => Net::HTTP.get(URI.parse("http://gemcutter.org/gems/bard.json")).match(/"version":"([0-9.]+)"/)[1],
|
20
21
|
'git' => '1.6.4',
|
21
22
|
'rubygems' => '1.3.4',
|
22
23
|
'ruby' => '1.8.6'
|
@@ -97,6 +98,20 @@ class Bard < Thor
|
|
97
98
|
# git post-receive hook runs stage task below
|
98
99
|
end
|
99
100
|
|
101
|
+
desc "deploy", "pushes, merges integration branch into master and deploys it to production"
|
102
|
+
def deploy
|
103
|
+
invoke :push
|
104
|
+
run_crucial "git fetch origin"
|
105
|
+
run_crucial "git checkout master"
|
106
|
+
run_crucial "git pull --rebase origin master"
|
107
|
+
if not fast_forward_merge? "master", "integration"
|
108
|
+
fatal "master has advanced since last deploy, probably due to a bugfix. rebase your integration branch on top of it, and check for breakage."
|
109
|
+
end
|
110
|
+
|
111
|
+
run_crucial "git merge integration"
|
112
|
+
run_crucial "git push origin master"
|
113
|
+
end
|
114
|
+
|
100
115
|
if ENV['RAILS_ENV'] == "staging"
|
101
116
|
desc "stage", "!!! INTERNAL USE ONLY !!! reset HEAD to integration, update submodules, run migrations, install gems, restart server"
|
102
117
|
def stage
|
@@ -114,28 +129,31 @@ class Bard < Thor
|
|
114
129
|
head = File.read('.git/HEAD').chomp
|
115
130
|
# abort if we're on a detached head
|
116
131
|
exit unless head.sub! 'ref: ', ''
|
132
|
+
if head == "master"
|
133
|
+
run_crucial "cap deploy"
|
134
|
+
else
|
135
|
+
revs = gets.split ' '
|
136
|
+
old_rev, new_rev = revs if head == revs.pop
|
117
137
|
|
118
|
-
|
119
|
-
old_rev, new_rev = revs if head == revs.pop
|
120
|
-
|
121
|
-
changed_files = run_crucial("git diff #{old_rev} #{new_rev} --diff-filter=ACMRD --name-only").split("\n")
|
138
|
+
changed_files = run_crucial("git diff #{old_rev} #{new_rev} --diff-filter=ACMRD --name-only").split("\n")
|
122
139
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
140
|
+
if changed_files.any? { |f| f =~ %r(^db/migrate/.+) }
|
141
|
+
run_crucial "rake db:migrate RAILS_ENV=staging"
|
142
|
+
run_crucial "rake db:migrate RAILS_ENV=test"
|
143
|
+
end
|
144
|
+
|
145
|
+
if changed_files.any? { |f| f == ".gitmodules" }
|
146
|
+
run_crucial "git submodule sync"
|
147
|
+
run_crucial "git submodule init"
|
148
|
+
end
|
149
|
+
system "git submodule update"
|
127
150
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
system "git submodule update"
|
133
|
-
|
134
|
-
if changed_files.any? { |f| f =~ %r(^config/environment.+) }
|
135
|
-
run_crucial "rake gems:install"
|
136
|
-
end
|
151
|
+
if changed_files.any? { |f| f =~ %r(^config/environment.+) }
|
152
|
+
run_crucial "rake gems:install"
|
153
|
+
end
|
137
154
|
|
138
|
-
|
155
|
+
system "touch tmp/restart.txt"
|
156
|
+
end
|
139
157
|
end
|
140
158
|
end
|
141
159
|
|
data/lib/bard/git.rb
CHANGED
@@ -10,12 +10,12 @@ module BardGit
|
|
10
10
|
fatal "Cannot upload changes: You have uncommitted changes!\n Please run git commit before attempting to push or pull."
|
11
11
|
end
|
12
12
|
|
13
|
-
def fast_forward_merge?
|
13
|
+
def fast_forward_merge?(root = "origin/integration", branch = "HEAD")
|
14
14
|
run_crucial "git fetch origin"
|
15
|
-
|
16
|
-
|
17
|
-
@common_ancestor = find_common_ancestor
|
18
|
-
@common_ancestor ==
|
15
|
+
root_head = run_crucial "git rev-parse #{root}"
|
16
|
+
branch_head = run_crucial "git rev-parse #{branch}"
|
17
|
+
@common_ancestor = find_common_ancestor root_head, branch_head
|
18
|
+
@common_ancestor == root_head
|
19
19
|
end
|
20
20
|
|
21
21
|
def find_common_ancestor(head1, head2)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- bard.gemspec
|
124
124
|
- bin/bard
|
125
125
|
- features/bard_check.feature
|
126
|
+
- features/bard_deploy.feature
|
126
127
|
- features/bard_pull.feature
|
127
128
|
- features/bard_push.feature
|
128
129
|
- features/step_definitions/check_steps.rb
|