waggit 0.0.009 → 0.0.011
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.
- checksums.yaml +4 -4
- data/bin/waggit +5 -3
- data/lib/command.rb +21 -3
- data/lib/git.rb +8 -1
- data/lib/waggit.rb +146 -92
- data/lib/wagon.rb +33 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb6f12cca80872d6f3abf76d06d91e70e9f37b53
|
|
4
|
+
data.tar.gz: 6422510225fd24c204c13d58872a5e3aed54ce08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ead58380a6ad904aa0aa36c5239345ea51f2e7ffdd0da5d9ced0ea9d24dd616c1b17f5aa5ae255c41b2815fa3001bc3d526e42e80a25db249a5e9d603d0e7c24
|
|
7
|
+
data.tar.gz: 7b4e59fe4bc7211233d0cb227f2d3c41c0156fb96188b507cb292905e6498d34e4dfd19fb54c257f961bd1d97cca9c635555ae1eaf1dfc67c45ef276bddc1f60
|
data/bin/waggit
CHANGED
|
@@ -4,9 +4,9 @@ require 'waggit.rb'
|
|
|
4
4
|
|
|
5
5
|
cmd = ARGV[0].downcase
|
|
6
6
|
|
|
7
|
-
for arg in ARGV
|
|
8
|
-
puts "arg: #{arg}"
|
|
9
|
-
end
|
|
7
|
+
#for arg in ARGV
|
|
8
|
+
#puts "arg: #{arg}"
|
|
9
|
+
#end
|
|
10
10
|
|
|
11
11
|
options = []
|
|
12
12
|
if ARGV.length > 1
|
|
@@ -25,6 +25,8 @@ when "pull"
|
|
|
25
25
|
Waggit.pull(options)
|
|
26
26
|
when "c", "clean"
|
|
27
27
|
Waggit.clean(options)
|
|
28
|
+
when "t", "test"
|
|
29
|
+
Waggit.test_dir(options)
|
|
28
30
|
else
|
|
29
31
|
puts "Invalid command!"
|
|
30
32
|
end
|
data/lib/command.rb
CHANGED
|
@@ -3,11 +3,29 @@
|
|
|
3
3
|
#
|
|
4
4
|
module Command
|
|
5
5
|
|
|
6
|
-
# Runs a command and
|
|
6
|
+
# Runs a command and passes output to standard out,
|
|
7
|
+
# and returns the result
|
|
7
8
|
#
|
|
8
|
-
def self.run(command)
|
|
9
|
-
|
|
9
|
+
def self.run(command, output = true)
|
|
10
|
+
IO.popen "#{command}" do |fd|
|
|
11
|
+
if output
|
|
12
|
+
until fd.eof?
|
|
13
|
+
puts fd.readline
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
return $?.success?
|
|
10
18
|
end
|
|
19
|
+
#Open3.capture3( "#{command}") do |stdin, stdout, status|
|
|
20
|
+
# if output
|
|
21
|
+
# until stdin.eof?
|
|
22
|
+
# stdout.puts stdin.readline
|
|
23
|
+
# end
|
|
24
|
+
# end
|
|
25
|
+
#return status.success?
|
|
26
|
+
#end
|
|
27
|
+
#return `#{command}`
|
|
28
|
+
#end
|
|
11
29
|
|
|
12
30
|
|
|
13
31
|
end
|
data/lib/git.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'command
|
|
1
|
+
require 'command'
|
|
2
2
|
|
|
3
3
|
module Git
|
|
4
4
|
|
|
@@ -104,4 +104,11 @@ module Git
|
|
|
104
104
|
puts "This does nothin yet"
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
# Return true if the provided directory is in a git repo, otherwise false. Can optionally provide wa
|
|
108
|
+
#
|
|
109
|
+
def self.is_git_dir?(dir = Dir.pwd)
|
|
110
|
+
return Dir.chdir dir do
|
|
111
|
+
return Command.run("git rev-parse", false)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
107
114
|
end
|
data/lib/waggit.rb
CHANGED
|
@@ -1,122 +1,176 @@
|
|
|
1
|
-
require 'git
|
|
2
|
-
require 'wagon
|
|
3
|
-
require 'files
|
|
1
|
+
require 'git'
|
|
2
|
+
require 'wagon'
|
|
3
|
+
require 'files'
|
|
4
4
|
|
|
5
5
|
module Waggit
|
|
6
6
|
|
|
7
7
|
# Verifies that the current working directory is setup to work with both git and wagon
|
|
8
8
|
#
|
|
9
|
-
def self.
|
|
10
|
-
|
|
9
|
+
def self.test_dir(options={})
|
|
10
|
+
test = true
|
|
11
|
+
if !Git.is_git_dir?
|
|
12
|
+
# FIXME: Cannot find a way to capture the output of the above git method,
|
|
13
|
+
# so there is another error that is output: 'fatal: Not a git repository
|
|
14
|
+
# (or any of the parent directories): .git'
|
|
15
|
+
|
|
16
|
+
#puts "error: not in a git directory."
|
|
17
|
+
test = false
|
|
18
|
+
end
|
|
19
|
+
if !Wagon.is_wagon_dir?
|
|
20
|
+
puts "error: Not in a wagon directory."
|
|
21
|
+
test = false
|
|
22
|
+
end
|
|
23
|
+
if test
|
|
24
|
+
puts "Current directory is both a wagon and a git directory"
|
|
25
|
+
end
|
|
26
|
+
return test
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Waggit can only really work if it is in a directory that has both git and
|
|
30
|
+
# wagon setup. This finds an appropriate working directory with both waggit
|
|
31
|
+
# and git and return the path as a string or return nil.
|
|
32
|
+
#
|
|
33
|
+
def self.get_waggit_dir()
|
|
34
|
+
dir = Wagon.get_wagon_path
|
|
35
|
+
puts "error: Unable to find a Wagon directory in your current path." unless dir
|
|
36
|
+
if dir
|
|
37
|
+
dir = Git.is_git_dir?(dir) ? dir : nil
|
|
38
|
+
puts "error: Wagon directory is not setup with git: #{dir}" unless dir
|
|
39
|
+
end
|
|
40
|
+
return dir
|
|
11
41
|
end
|
|
12
42
|
|
|
13
|
-
def self.clean(options)
|
|
14
|
-
|
|
43
|
+
def self.clean(options={})
|
|
44
|
+
dir = get_waggit_dir
|
|
45
|
+
if dir
|
|
46
|
+
Dir.chdir(dir) do
|
|
47
|
+
Files.clean_css
|
|
48
|
+
end
|
|
49
|
+
end
|
|
15
50
|
end
|
|
16
51
|
|
|
17
52
|
# Push local changes to wagon, ignoring git.
|
|
18
53
|
#
|
|
19
54
|
def self.forcepush(options)
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
dir = get_waggit_dir
|
|
56
|
+
if dir
|
|
57
|
+
Dir.chdir(dir) do
|
|
58
|
+
Files.clean_css
|
|
59
|
+
Wagon.push(options)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
22
62
|
end
|
|
23
63
|
|
|
24
64
|
# Commit local changes and keep in sync with git, then push to wagon.
|
|
25
65
|
#
|
|
26
66
|
def self.push(options)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
67
|
+
dir = get_waggit_dir
|
|
68
|
+
if dir
|
|
69
|
+
Dir.chdir(dir) do
|
|
70
|
+
Git.add_all
|
|
71
|
+
Git.commit_prompt
|
|
72
|
+
Files.clean_css
|
|
73
|
+
if Git.has_changes?
|
|
74
|
+
Git.add_all
|
|
75
|
+
Git.commit "cleaned css"
|
|
76
|
+
end
|
|
77
|
+
Git.pull
|
|
78
|
+
Git.push
|
|
79
|
+
Wagon.push(options)
|
|
80
|
+
end
|
|
33
81
|
end
|
|
34
|
-
puts Git.pull
|
|
35
|
-
puts Git.push
|
|
36
|
-
puts Wagon.push(options)
|
|
37
82
|
end
|
|
38
83
|
|
|
39
84
|
def self.pull(options)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
85
|
+
dir = get_waggit_dir
|
|
86
|
+
if dir
|
|
87
|
+
Dir.chdir(dir) do
|
|
88
|
+
begin
|
|
89
|
+
Git.checkout_master
|
|
90
|
+
Git.delete_wagon
|
|
91
|
+
Git.delete_local
|
|
92
|
+
Git.stash
|
|
93
|
+
|
|
94
|
+
Git.checkout_new_wagon
|
|
95
|
+
Wagon.pull(options)
|
|
96
|
+
#TODO: Checkout: http://stackoverflow.com/questions/3515597/git-add-only-non-whitespace-changes
|
|
97
|
+
if Git.has_changes?
|
|
98
|
+
Git.add_all
|
|
99
|
+
Git.commit "merge wagon pull"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
Git.checkout_master
|
|
103
|
+
Git.rebase_wagon
|
|
104
|
+
Git.checkout_master
|
|
105
|
+
Git.merge_wagon
|
|
106
|
+
|
|
107
|
+
Git.checkout_new_local
|
|
108
|
+
Git.stash_pop
|
|
109
|
+
Git.add_all
|
|
110
|
+
Git.commit_prompt
|
|
111
|
+
Git.rebase_local
|
|
112
|
+
Git.checkout_master
|
|
113
|
+
Git.merge_local
|
|
114
|
+
Git.delete_wagon
|
|
115
|
+
Git.delete_local
|
|
116
|
+
rescue Exception
|
|
117
|
+
"Pull aborted, switching back to master branch"
|
|
118
|
+
Git.checkout_master
|
|
119
|
+
raise
|
|
120
|
+
end
|
|
52
121
|
end
|
|
53
|
-
|
|
54
|
-
puts Git.checkout_master
|
|
55
|
-
puts Git.rebase_wagon
|
|
56
|
-
puts Git.checkout_master
|
|
57
|
-
puts Git.merge_wagon
|
|
58
|
-
|
|
59
|
-
puts Git.checkout_new_local
|
|
60
|
-
puts Git.stash_pop
|
|
61
|
-
puts Git.add_all
|
|
62
|
-
puts Git.commit_prompt
|
|
63
|
-
puts Git.rebase_local
|
|
64
|
-
puts Git.checkout_master
|
|
65
|
-
puts Git.merge_local
|
|
66
|
-
puts Git.delete_wagon
|
|
67
|
-
puts Git.delete_local
|
|
68
|
-
rescue Exception
|
|
69
|
-
puts "Pull aborted, switching back to master branch"
|
|
70
|
-
puts Git.checkout_master
|
|
71
|
-
raise
|
|
72
122
|
end
|
|
73
|
-
|
|
74
123
|
end
|
|
75
124
|
|
|
76
125
|
def self.sync(options)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
126
|
+
dir = get_waggit_dir
|
|
127
|
+
if dir
|
|
128
|
+
Dir.chdir(dir) do
|
|
129
|
+
begin
|
|
130
|
+
Git.checkout_master
|
|
131
|
+
Git.delete_wagon
|
|
132
|
+
Git.delete_local
|
|
133
|
+
Git.stash
|
|
134
|
+
|
|
135
|
+
Git.checkout_new_wagon
|
|
136
|
+
Wagon.pull(options)
|
|
137
|
+
#TODO: Checkout: http://stackoverflow.com/questions/3515597/git-add-only-non-whitespace-changes
|
|
138
|
+
if Git.has_changes?
|
|
139
|
+
Git.add_all
|
|
140
|
+
Git.commit "merge wagon pull"
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
Git.checkout_master
|
|
144
|
+
Git.rebase_wagon
|
|
145
|
+
Git.checkout_master
|
|
146
|
+
Git.merge_wagon
|
|
147
|
+
|
|
148
|
+
Git.checkout_new_local
|
|
149
|
+
Git.stash_pop
|
|
150
|
+
Git.add_all
|
|
151
|
+
Git.commit_prompt
|
|
152
|
+
Git.rebase_local
|
|
153
|
+
Git.checkout_master
|
|
154
|
+
Git.merge_local
|
|
155
|
+
Git.delete_wagon
|
|
156
|
+
Git.delete_local
|
|
157
|
+
|
|
158
|
+
Files.clean_css
|
|
159
|
+
if Git.has_changes?
|
|
160
|
+
Git.add_all
|
|
161
|
+
Git.commit "cleaned css"
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
Git.pull
|
|
165
|
+
Git.push
|
|
166
|
+
|
|
167
|
+
Wagon.push(options)
|
|
168
|
+
rescue Exception
|
|
169
|
+
"Sync aborted, switching back to master branch"
|
|
170
|
+
Git.checkout_master
|
|
171
|
+
raise
|
|
172
|
+
end
|
|
89
173
|
end
|
|
90
|
-
|
|
91
|
-
puts Git.checkout_master
|
|
92
|
-
puts Git.rebase_wagon
|
|
93
|
-
puts Git.checkout_master
|
|
94
|
-
puts Git.merge_wagon
|
|
95
|
-
|
|
96
|
-
puts Git.checkout_new_local
|
|
97
|
-
puts Git.stash_pop
|
|
98
|
-
puts Git.add_all
|
|
99
|
-
puts Git.commit_prompt
|
|
100
|
-
puts Git.rebase_local
|
|
101
|
-
puts Git.checkout_master
|
|
102
|
-
puts Git.merge_local
|
|
103
|
-
puts Git.delete_wagon
|
|
104
|
-
puts Git.delete_local
|
|
105
|
-
|
|
106
|
-
Files.clean_css
|
|
107
|
-
if Git.has_changes?
|
|
108
|
-
puts Git.add_all
|
|
109
|
-
puts Git.commit "cleaned css"
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
puts Git.pull
|
|
113
|
-
puts Git.push
|
|
114
|
-
|
|
115
|
-
puts Wagon.push(options)
|
|
116
|
-
rescue Exception
|
|
117
|
-
puts "Sync aborted, switching back to master branch"
|
|
118
|
-
puts Git.checkout_master
|
|
119
|
-
raise
|
|
120
174
|
end
|
|
121
175
|
end
|
|
122
176
|
|
data/lib/wagon.rb
CHANGED
|
@@ -52,8 +52,6 @@ module Wagon
|
|
|
52
52
|
else
|
|
53
53
|
return ''
|
|
54
54
|
end
|
|
55
|
-
|
|
56
|
-
|
|
57
55
|
end
|
|
58
56
|
|
|
59
57
|
def self.pull(options)
|
|
@@ -64,4 +62,37 @@ module Wagon
|
|
|
64
62
|
Command.run("bundle exec wagon push production#{self.process_options(options)}")
|
|
65
63
|
end
|
|
66
64
|
|
|
65
|
+
|
|
66
|
+
# FROM : https://github.com/locomotivecms/wagon/blob/master/lib/locomotive/wagon/cli.rb#L8-L31
|
|
67
|
+
# This method is heavily tweaked and may require more modifications to be acurate.
|
|
68
|
+
# Check if the path given in option ('.' by default) points to a LocomotiveCMS
|
|
69
|
+
# site. It is also possible to pass a path other than the one from the options.
|
|
70
|
+
#
|
|
71
|
+
# @param [ String ] path The optional path of the site instead of options['path']
|
|
72
|
+
#
|
|
73
|
+
# @return [ String ] The fullpath to the LocomotiveCMS site or nil if it is not a valid site.
|
|
74
|
+
#
|
|
75
|
+
def self.is_wagon_dir?(path = '.')
|
|
76
|
+
path = path == '.' ? Dir.pwd : File.expand_path(path)
|
|
77
|
+
return File.exists?(File.join(path, 'config', 'site.yml'))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Determines if there is a wagon path in the immediate directory or the directory above it.
|
|
81
|
+
# If so, the path will be returned, otherwise nill. This does not search sub directories.
|
|
82
|
+
def self.get_wagon_path()
|
|
83
|
+
dir = nil
|
|
84
|
+
if is_wagon_dir? Dir.pwd
|
|
85
|
+
dir = Dir.pwd
|
|
86
|
+
else
|
|
87
|
+
require 'pathname'
|
|
88
|
+
Pathname.new(Dir.pwd).ascend do |parent|
|
|
89
|
+
if is_wagon_dir? parent
|
|
90
|
+
dir = parent.to_s
|
|
91
|
+
break
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
return dir
|
|
96
|
+
end
|
|
97
|
+
|
|
67
98
|
end
|