gitscape 1.4.1 → 1.5
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/bin/gitscape +27 -14
- data/lib/gitscape/base.rb +31 -14
- data/lib/gitscape/version.rb +1 -1
- metadata +2 -3
data/bin/gitscape
CHANGED
@@ -30,34 +30,47 @@ options = {}
|
|
30
30
|
op = OptionParser.new do |op|
|
31
31
|
op.banner = 'Usage: gitscape [action] [options]'
|
32
32
|
op.separator('Options:')
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
op.on '--[no-]trace', 'Verbose output for debugging' do |bool|
|
35
|
+
options[:trace] = bool
|
35
36
|
end
|
37
|
+
|
36
38
|
op.on '-h', '--help', 'Show a list of actions' do
|
37
39
|
puts OVERVIEW
|
38
40
|
exit
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
+
op.on '-p', '--[no-]push', 'Whether or not to push changes to origin' do |bool|
|
44
|
+
options[:push] = bool
|
45
|
+
end
|
46
|
+
|
47
|
+
op.on '-u', '--[no-]update-env', 'Whether to update environment branches when their development branch is updated' do |bool|
|
48
|
+
options[:update_env] = bool
|
49
|
+
end
|
50
|
+
|
51
|
+
op.on '-e', '--env-depth=ENV', [:staging, :qa, :live], 'The level of environments to push changes to' do |depth|
|
52
|
+
options[:env_depth] = depth
|
53
|
+
end
|
54
|
+
end
|
43
55
|
|
44
|
-
|
45
|
-
# so that it doesn't conflict with the 'app' subdirectory.
|
56
|
+
op.parse!(ARGV)
|
46
57
|
|
47
58
|
if ARGV.size < 1
|
48
|
-
puts
|
49
|
-
exit
|
59
|
+
puts OVERVIEW
|
60
|
+
exit
|
50
61
|
else
|
51
|
-
|
62
|
+
command_name = ARGV[0]
|
63
|
+
case command_name
|
52
64
|
when "hotfix_start"
|
53
|
-
|
65
|
+
hotfix_branch = ARGV[1]
|
66
|
+
Gitscape::Base.new.hotfix_start hotfix_branch, options
|
54
67
|
when "hotfix_finish"
|
55
|
-
Gitscape::Base.new.hotfix_finish
|
68
|
+
Gitscape::Base.new.hotfix_finish hotfix_branch, options
|
56
69
|
when "release_start"
|
57
|
-
Gitscape::Base.new.release_start
|
70
|
+
Gitscape::Base.new.release_start options
|
58
71
|
when "release_finish"
|
59
|
-
Gitscape::Base.new.release_finish
|
72
|
+
Gitscape::Base.new.release_finish options
|
60
73
|
else
|
61
|
-
puts "Unknown command"
|
74
|
+
puts "Unknown command: #{command_name}"
|
62
75
|
end
|
63
76
|
end
|
data/lib/gitscape/base.rb
CHANGED
@@ -9,16 +9,24 @@ class Gitscape::Base
|
|
9
9
|
|
10
10
|
# Always add a merge commit at the end of a merge
|
11
11
|
@merge_options = "--no-ff"
|
12
|
+
|
12
13
|
# Setup additional merge options based on the version of Git we have
|
13
14
|
if git_version_at_least "1.7.4.0"
|
14
15
|
@merge_options += " -s recursive -Xignore-space-change"
|
15
16
|
else
|
16
17
|
warn "Ignoring whitespace changes in merges is only available on Git 1.7.4+"
|
17
18
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
|
20
|
+
@env_branch_by_dev_branch = Hash.new do |h, k|
|
21
|
+
case k
|
22
|
+
when "master"
|
23
|
+
"staging"
|
24
|
+
when /release\/i\d+/
|
25
|
+
"qa"
|
26
|
+
when "live"
|
27
|
+
"live"
|
28
|
+
end
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
def git_working_copy_is_clean puts_changes=true
|
@@ -80,9 +88,11 @@ class Gitscape::Base
|
|
80
88
|
puts `git checkout -b #{hotfix_branch}`
|
81
89
|
end
|
82
90
|
|
83
|
-
def hotfix_finish
|
84
|
-
#
|
85
|
-
|
91
|
+
def hotfix_finish hotfix_branch="", options={:env_depth=>:staging, :push=>true, :update_env=>true}
|
92
|
+
# option defaults
|
93
|
+
options[:env_depth] = :staging if options[:env_depth].nil?
|
94
|
+
options[:push] = true if options[:push].nil?
|
95
|
+
options[:update_env] = true if options[:update_env].nil?
|
86
96
|
|
87
97
|
usage_string = "expected usage: hotfix_finish [<hotfix_branch>]
|
88
98
|
hotfix_branch: the name of the hotfix branch to finish.
|
@@ -101,9 +111,12 @@ class Gitscape::Base
|
|
101
111
|
end
|
102
112
|
|
103
113
|
# Collect the set of branches we'd like to merge the hotfix into
|
104
|
-
merge_branches = ["master"
|
114
|
+
merge_branches = ["master"]
|
115
|
+
merge_branches << current_release_branch_name if [:qa, :live].include?(options[:env_depth])
|
116
|
+
merge_branches << "live" if options[:env_depth] == :live
|
105
117
|
|
106
118
|
# Merge the hotfix into merge_branches
|
119
|
+
puts "=== Merging hotfix into branches #{merge_branches} ==="
|
107
120
|
for branch in merge_branches
|
108
121
|
|
109
122
|
# Calculate merge_options
|
@@ -111,17 +124,21 @@ class Gitscape::Base
|
|
111
124
|
merge_options += " --log" if branch == "master"
|
112
125
|
|
113
126
|
# Attempt merge
|
114
|
-
`git checkout #{branch}`
|
115
|
-
`git
|
127
|
+
puts `git checkout #{branch}`
|
128
|
+
puts `git pull`
|
129
|
+
puts `git merge #{merge_options} #{hotfix_branch}`
|
116
130
|
|
117
131
|
# Bail on failures
|
118
132
|
exit 1 if !$?.success?
|
119
|
-
raise "Merge on #{branch}
|
120
|
-
|
133
|
+
raise "Merge failure(s) on #{branch}.\nResolve conflicts, and run the script again." if git_has_conflicts
|
134
|
+
|
135
|
+
puts `git push origin #{branch}` if options[:push]
|
136
|
+
puts `git push origin #{branch}:#{@env_branch_by_dev_branch[branch]}` if options[:update_env]
|
137
|
+
|
121
138
|
# If we just merged the live branch, tag this revision, and push that tag to origin
|
122
139
|
if branch == "live"
|
123
|
-
`git tag live/i#{live_iteration}/#{hotfix_branch}`
|
124
|
-
`git push --tags`
|
140
|
+
puts `git tag live/i#{live_iteration}/#{hotfix_branch}`
|
141
|
+
puts `git push --tags`
|
125
142
|
end
|
126
143
|
|
127
144
|
end
|
data/lib/gitscape/version.rb
CHANGED