stencil 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/gemspec.rb +1 -1
- data/lib/stencil/merge.rb +32 -17
- data/lib/stencil/msg.rb +11 -6
- data/stencil.gemspec +1 -1
- metadata +1 -1
data/gemspec.rb
CHANGED
data/lib/stencil/merge.rb
CHANGED
@@ -5,23 +5,26 @@ class Stencil
|
|
5
5
|
def project(name, path)
|
6
6
|
template = Config.read[:projects][name][:template]
|
7
7
|
branches = Config.read[:projects][name][:branches]
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
Msg.error_specify_template unless template
|
9
|
+
template = Config.read[:templates][template.intern]
|
10
|
+
if template && File.exists?(template[:path])
|
11
|
+
|
12
|
+
# Add remote template to project
|
13
|
+
origin = get_origin template[:path]
|
14
|
+
Msg.template_url origin
|
15
|
+
add_remote 'template', path, origin
|
16
|
+
|
17
|
+
# Pull template into master if no branches specified
|
18
|
+
branches = %w(master) if branches.empty?
|
19
|
+
|
20
|
+
# Pull template into each branch
|
21
|
+
branches.each do |branch|
|
22
|
+
Msg.merge_remote_branch branch
|
23
|
+
Cmd.run path, "git pull template #{branch}"
|
22
24
|
end
|
23
25
|
else
|
24
|
-
Msg.
|
26
|
+
Msg.template_not_found template
|
27
|
+
Msg.error_specify_template
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -33,20 +36,32 @@ class Stencil
|
|
33
36
|
Cmd.run path, "git checkout master"
|
34
37
|
end
|
35
38
|
|
36
|
-
def upstream(name, commit, branches=[])
|
39
|
+
def upstream(name, commit=nil, branches=[])
|
40
|
+
# Project variables
|
37
41
|
project = Config.read[:projects][name]
|
38
42
|
branch = Cmd.run(project[:path], "git branch").split
|
39
43
|
branch = branch[branch.index('*') + 1]
|
40
44
|
|
45
|
+
# Template variables
|
41
46
|
template = Config.read[:templates][project[:template].intern]
|
42
47
|
path = template[:path]
|
43
48
|
|
49
|
+
# Add remote project to template and fetch
|
44
50
|
origin = get_origin project[:path]
|
45
51
|
Msg.project_url origin
|
46
52
|
add_remote 'project', path, origin
|
47
53
|
Cmd.run path, "git fetch project"
|
48
54
|
|
55
|
+
# Get last commit if none specified
|
56
|
+
unless commit
|
57
|
+
cmd = "git log HEAD~1..HEAD --pretty=format:'%H'"
|
58
|
+
commit = Cmd.run(template[:path], cmd).strip
|
59
|
+
end
|
60
|
+
|
61
|
+
# Cherry pick into master if no branches specified
|
49
62
|
branches = %w(master) if branches.empty?
|
63
|
+
|
64
|
+
# Cherry pick commit into branches
|
50
65
|
branches.each do |branch|
|
51
66
|
output = Cmd.run path, "git checkout #{branch}"
|
52
67
|
Msg.error(output) if output.downcase.include?('error')
|
@@ -74,7 +89,7 @@ class Stencil
|
|
74
89
|
merger = branches.shift
|
75
90
|
mergee = branches.first
|
76
91
|
if merger && mergee
|
77
|
-
|
92
|
+
Msg.merging_x_into_y merger, mergee
|
78
93
|
output = Cmd.run path, "git checkout #{mergee}"
|
79
94
|
Msg.error(output) if output.downcase.include?('error')
|
80
95
|
output = Cmd.run path, "git merge #{merger}"
|
data/lib/stencil/msg.rb
CHANGED
@@ -13,6 +13,13 @@ class Stencil
|
|
13
13
|
exit
|
14
14
|
end
|
15
15
|
|
16
|
+
def error_specify_template
|
17
|
+
space
|
18
|
+
puts "Please tell stencil what template you want to receive updates from:"
|
19
|
+
puts " stencil TEMPLATE [BRANCH BRANCH ...]"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
16
23
|
def is_template_or_project?(name)
|
17
24
|
space
|
18
25
|
puts "Is \"#{name}\" a template or a project?"
|
@@ -23,6 +30,10 @@ class Stencil
|
|
23
30
|
puts "Merging remote branch \"#{branch}\""
|
24
31
|
end
|
25
32
|
|
33
|
+
def merging_x_into_y(x, y)
|
34
|
+
puts "Merging \"#{x}\" into \"#{y}\""
|
35
|
+
end
|
36
|
+
|
26
37
|
def project_url(url)
|
27
38
|
space
|
28
39
|
puts "Found project URL: #{url}"
|
@@ -32,12 +43,6 @@ class Stencil
|
|
32
43
|
puts ''
|
33
44
|
end
|
34
45
|
|
35
|
-
def specify_template
|
36
|
-
space
|
37
|
-
puts "Please tell stencil what template you want to receive updates from:"
|
38
|
-
puts " stencil TEMPLATE [BRANCH BRANCH ...]"
|
39
|
-
end
|
40
|
-
|
41
46
|
def template_not_found(template)
|
42
47
|
space
|
43
48
|
puts "Template \"#{template}\" not found."
|
data/stencil.gemspec
CHANGED