acmcommits 0.0.1
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/.gitignore +12 -0
- data/.travis.yml +20 -0
- data/CHANGELOG +99 -0
- data/CONTRIBUTING +11 -0
- data/Gemfile +4 -0
- data/LICENSE +165 -0
- data/README.md +74 -0
- data/Rakefile +69 -0
- data/acmcommits.gemspec +39 -0
- data/bin/lolcommits +309 -0
- data/features/bugs.feature +58 -0
- data/features/lolcommits.feature +147 -0
- data/features/plugins.feature +34 -0
- data/features/step_definitions/lolcommits_steps.rb +98 -0
- data/features/support/env.rb +94 -0
- data/lib/core_ext/class.rb +7 -0
- data/lib/lolcommits/capture_fake.rb +10 -0
- data/lib/lolcommits/capture_linux.rb +28 -0
- data/lib/lolcommits/capture_mac.rb +19 -0
- data/lib/lolcommits/capture_windows.rb +18 -0
- data/lib/lolcommits/capturer.rb +13 -0
- data/lib/lolcommits/configuration.rb +160 -0
- data/lib/lolcommits/git_info.rb +27 -0
- data/lib/lolcommits/plugin.rb +40 -0
- data/lib/lolcommits/plugins/lolsrv.rb +73 -0
- data/lib/lolcommits/plugins/loltext.rb +79 -0
- data/lib/lolcommits/plugins/statsd.rb +25 -0
- data/lib/lolcommits/runner.rb +97 -0
- data/lib/lolcommits/version.rb +3 -0
- data/lib/lolcommits.rb +27 -0
- data/test/images/test_image.jpg +0 -0
- data/test/test_lolcommits.rb +49 -0
- data/vendor/ext/CommandCam/COPYING +674 -0
- data/vendor/ext/CommandCam/CommandCam.exe +0 -0
- data/vendor/ext/CommandCam/LICENSE +16 -0
- data/vendor/ext/imagesnap/ReadMeOrDont.rtf +117 -0
- data/vendor/ext/imagesnap/imagesnap +0 -0
- data/vendor/fonts/Impact.ttf +0 -0
- metadata +228 -0
data/bin/lolcommits
ADDED
@@ -0,0 +1,309 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'lolcommits'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'lolcommits'
|
8
|
+
end
|
9
|
+
|
10
|
+
include Lolcommits
|
11
|
+
require "launchy"
|
12
|
+
require "choice"
|
13
|
+
|
14
|
+
require 'methadone'
|
15
|
+
include Methadone::CLILogging
|
16
|
+
|
17
|
+
#
|
18
|
+
# CHECK FOR FURTHER DEPENDENCIES
|
19
|
+
#
|
20
|
+
|
21
|
+
# which replacement http://stackoverflow.com/q/2108727
|
22
|
+
def command?(name)
|
23
|
+
`which #{name}`
|
24
|
+
$?.success?
|
25
|
+
end
|
26
|
+
|
27
|
+
def die_on_fatal_conditions!
|
28
|
+
if Configuration.is_mac?
|
29
|
+
unless File.executable? File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")
|
30
|
+
fatal "Couldn't properly execute imagesnap for some reason, please file a bug?!"
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
elsif Configuration.is_linux?
|
34
|
+
if not command?('mplayer')
|
35
|
+
fatal "Couldn't find mplayer in your PATH!"
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
unless File.readable? File.join(Configuration::LOLCOMMITS_ROOT, "vendor", "fonts", "Impact.ttf")
|
40
|
+
fatal "Couldn't properly read Impact font from gem package, please file a bug?!"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
unless Configuration.valid_imagemagick_installed?
|
44
|
+
fatal "FATAL: ImageMagick does not appear to be properly installed!"
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
if Configuration.git_config_color_always?
|
48
|
+
fatal "Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'."
|
49
|
+
fatal "Try setting it to 'auto' instead!"
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def die_if_not_git_repo!
|
55
|
+
begin
|
56
|
+
debug "Checking for valid git repo"
|
57
|
+
g=Git.open('.')
|
58
|
+
rescue ArgumentError
|
59
|
+
# ruby-git throws an argument error if path isnt for a valid git repo...
|
60
|
+
fatal "Erm? Can't do that since we're not in a valid git repository!"
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# NO ARGUMENTS SPECIFIED, HELP THE USER OUT
|
67
|
+
#
|
68
|
+
def do_noargs
|
69
|
+
#TODO: make this a contextual helper to know status of whether lolcommits is enabled
|
70
|
+
puts "Do what exactly?"
|
71
|
+
puts "Try: lolcommits --enable (when in a git repository)"
|
72
|
+
puts "Or: lolcommits --help"
|
73
|
+
end
|
74
|
+
|
75
|
+
HOOK_PATH = File.join ".git", "hooks", "post-commit"
|
76
|
+
HOOK_DIR = File.join ".git", "hooks"
|
77
|
+
|
78
|
+
#
|
79
|
+
# IF --ENABLE, DO ENABLE
|
80
|
+
#
|
81
|
+
def do_enable
|
82
|
+
if not File.directory?(".git")
|
83
|
+
fatal "You don't appear to be in the base directory of a git project."
|
84
|
+
exit 1
|
85
|
+
end
|
86
|
+
|
87
|
+
#its possible a hooks dir doesnt exist, so create it if so
|
88
|
+
if not File.directory?(HOOK_DIR)
|
89
|
+
Dir.mkdir(HOOK_DIR)
|
90
|
+
end
|
91
|
+
|
92
|
+
if File.exists? HOOK_PATH
|
93
|
+
fatal "A post-commit hook already exists for this project."
|
94
|
+
#TODO: disambiguate between OUR post-commit hook and something else
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
|
98
|
+
doc = "#!/bin/sh\nlolcommits --capture\n"
|
99
|
+
File.open(HOOK_PATH, 'w') {|f| f.write(doc) }
|
100
|
+
FileUtils.chmod 0755, HOOK_PATH
|
101
|
+
info "installed lolcommmit hook as:"
|
102
|
+
info " -> #{File.expand_path(HOOK_PATH)}"
|
103
|
+
info "(to remove later, you can use: lolcommits --disable)"
|
104
|
+
# we dont symlink, but rather install a small stub that calls the one from path
|
105
|
+
# that way, as gem version changes, script updates even if new file thus breaking symlink
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# IF --DISABLE, DO DISABLE
|
110
|
+
#
|
111
|
+
def do_disable
|
112
|
+
if File.exists? HOOK_PATH
|
113
|
+
#TODO: check if hook file has been modified before removing
|
114
|
+
FileUtils.rm HOOK_PATH
|
115
|
+
info "removed #{HOOK_PATH}"
|
116
|
+
else
|
117
|
+
info "lolcommits is not enabled for this directory, so there is nothing to uninstall."
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def configuration
|
122
|
+
if Choice.choices[:test]
|
123
|
+
Configuration.new(:loldir => Configuration.loldir_for('test'))
|
124
|
+
else
|
125
|
+
Configuration.new
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# IF --CAPTURE, DO CAPTURE
|
131
|
+
#
|
132
|
+
def do_capture
|
133
|
+
capture_delay = Choice.choices[:delay] || ENV['LOLCOMMITS_DELAY'] || 0
|
134
|
+
capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
|
135
|
+
capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil
|
136
|
+
|
137
|
+
if Choice.choices[:test]
|
138
|
+
info "*** Capturing in test mode."
|
139
|
+
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
|
140
|
+
:capture_device => capture_device,
|
141
|
+
:message => Choice.choices[:msg],
|
142
|
+
:sha => Choice.choices[:sha],
|
143
|
+
:config => configuration,
|
144
|
+
:font => capture_font
|
145
|
+
)
|
146
|
+
runner.run
|
147
|
+
|
148
|
+
Launchy.open(runner.main_image)
|
149
|
+
else
|
150
|
+
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
|
151
|
+
:capture_device => capture_device,
|
152
|
+
:config => configuration,
|
153
|
+
:font => capture_font
|
154
|
+
)
|
155
|
+
runner.run
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def do_configure
|
160
|
+
configuration.do_configure! Choice.choices[:plugin]
|
161
|
+
end
|
162
|
+
|
163
|
+
def do_last
|
164
|
+
die_if_not_git_repo!
|
165
|
+
lolimage = configuration.most_recent
|
166
|
+
if lolimage.nil?
|
167
|
+
warn "No lolcommits have been captured for this repository yet."
|
168
|
+
exit 1
|
169
|
+
end
|
170
|
+
Launchy.open lolimage
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Command line parsing fun
|
175
|
+
#
|
176
|
+
Choice.options do
|
177
|
+
|
178
|
+
option :enable do
|
179
|
+
long "--enable"
|
180
|
+
short '-e'
|
181
|
+
action { do_enable }
|
182
|
+
desc "install lolcommits for this repo"
|
183
|
+
end
|
184
|
+
|
185
|
+
option :disable do
|
186
|
+
long "--disable"
|
187
|
+
short '-d'
|
188
|
+
action { do_disable }
|
189
|
+
desc "uninstall lolcommits for this repo"
|
190
|
+
end
|
191
|
+
|
192
|
+
option :capture do
|
193
|
+
long "--capture"
|
194
|
+
short '-c'
|
195
|
+
desc "capture lolcommit based on last git commit"
|
196
|
+
end
|
197
|
+
|
198
|
+
option :last do
|
199
|
+
long "--last"
|
200
|
+
short "-l"
|
201
|
+
desc "view the most recent lolcommit"
|
202
|
+
end
|
203
|
+
|
204
|
+
option :browse do
|
205
|
+
long "--browse"
|
206
|
+
short "-b"
|
207
|
+
desc "browse this repo's lolcommits"
|
208
|
+
end
|
209
|
+
|
210
|
+
option :configure do
|
211
|
+
long "--config"
|
212
|
+
desc "configure a plugin"
|
213
|
+
end
|
214
|
+
|
215
|
+
option :show_config do
|
216
|
+
short "-sc"
|
217
|
+
long "--show-config"
|
218
|
+
desc "display configuration file"
|
219
|
+
end
|
220
|
+
|
221
|
+
option :plugin do
|
222
|
+
desc "pass plugin name for --config"
|
223
|
+
long "--plugin"
|
224
|
+
short "-p"
|
225
|
+
default nil
|
226
|
+
end
|
227
|
+
|
228
|
+
option :plugins do
|
229
|
+
desc "list all available plugins"
|
230
|
+
long "--plugins"
|
231
|
+
end
|
232
|
+
|
233
|
+
option :test do
|
234
|
+
long "--test"
|
235
|
+
desc "Run in test mode"
|
236
|
+
end
|
237
|
+
|
238
|
+
option :sha do
|
239
|
+
desc "pass SHA manually [TEST-MODE]"
|
240
|
+
long "--sha"
|
241
|
+
short '-s'
|
242
|
+
default "test-#{rand(10 ** 10)}"
|
243
|
+
end
|
244
|
+
|
245
|
+
option :msg do
|
246
|
+
desc "pass commit msg manually [TEST-MODE]"
|
247
|
+
long "--msg"
|
248
|
+
short '-m'
|
249
|
+
default "this is a test message i didnt really commit something"
|
250
|
+
end
|
251
|
+
|
252
|
+
option :delay do
|
253
|
+
long "--delay=SECONDS"
|
254
|
+
desc "delay taking of the snapshot by n seconds"
|
255
|
+
cast Integer
|
256
|
+
short '-w'
|
257
|
+
end
|
258
|
+
|
259
|
+
option :device do
|
260
|
+
long "--device=DEVICE"
|
261
|
+
desc "the device name used to take the snapshot (only mac)"
|
262
|
+
end
|
263
|
+
|
264
|
+
option :debug do
|
265
|
+
long "--debug"
|
266
|
+
desc "Output debugging information"
|
267
|
+
end
|
268
|
+
|
269
|
+
option :font do
|
270
|
+
long "--font=FONT_PATH"
|
271
|
+
short "-f"
|
272
|
+
desc "pass font file location"
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
# Set debug level if needed
|
278
|
+
debug_mode = Choice.choices[:debug] || ENV['LOLCOMMITS_DEBUG'] || nil
|
279
|
+
if debug_mode
|
280
|
+
logger.level = Logger::DEBUG
|
281
|
+
debug "Outputting at DEBUG verbosity"
|
282
|
+
end
|
283
|
+
|
284
|
+
#
|
285
|
+
# check for fatal conditions before execution
|
286
|
+
#
|
287
|
+
die_on_fatal_conditions!
|
288
|
+
|
289
|
+
#
|
290
|
+
# Handle actions manually since choice seems weird
|
291
|
+
#
|
292
|
+
if not (Choice.choices[:enable] || Choice.choices[:disable])
|
293
|
+
if Choice.choices[:capture]
|
294
|
+
do_capture()
|
295
|
+
elsif Choice.choices[:configure]
|
296
|
+
do_configure()
|
297
|
+
elsif Choice.choices[:show_config]
|
298
|
+
puts configuration.user_configuration.to_yaml
|
299
|
+
elsif Choice.choices[:plugins]
|
300
|
+
configuration.puts_plugins()
|
301
|
+
elsif Choice.choices[:last]
|
302
|
+
do_last()
|
303
|
+
elsif Choice.choices[:browse]
|
304
|
+
die_if_not_git_repo!
|
305
|
+
Launchy.open configuration.loldir
|
306
|
+
else
|
307
|
+
do_noargs()
|
308
|
+
end
|
309
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Feature: Bug regression testing
|
2
|
+
As a developer
|
3
|
+
I want to ensure fixed bugs stay fixed
|
4
|
+
So that I don't have to fix them again!
|
5
|
+
|
6
|
+
#
|
7
|
+
# issue #58, https://github.com/mroth/lolcommits/issues/58
|
8
|
+
#
|
9
|
+
Scenario: handle git repos with spaces in directory name
|
10
|
+
Given I am in a git repository named "test lolol" with lolcommits enabled
|
11
|
+
And I successfully run `git commit --allow-empty -m 'can haz commit'`
|
12
|
+
Then the output should contain "*** Preserving this moment in history."
|
13
|
+
And a directory named "../.lolcommits/test-lolol" should exist
|
14
|
+
|
15
|
+
#
|
16
|
+
# issue #68, https://github.com/mroth/lolcommits/issues/68
|
17
|
+
#
|
18
|
+
@fake-interactive-rebase @slow_process @unstable
|
19
|
+
Scenario: Don't trigger capture during a git rebase
|
20
|
+
Given I am in a git repository named "yuh8history" with lolcommits enabled
|
21
|
+
And I do 6 git commits
|
22
|
+
When I successfully run `git rebase -i HEAD~5`
|
23
|
+
# Then there should be 4 commit entries in the git log
|
24
|
+
Then there should be exactly 6 jpgs in "../.lolcommits/yuh8history"
|
25
|
+
|
26
|
+
#
|
27
|
+
# issue #80, https://github.com/mroth/lolcommits/issues/80
|
28
|
+
#
|
29
|
+
Scenario: don't warn about system_timer (on MRI 1.8.7)
|
30
|
+
When I successfully run `lolcommits`
|
31
|
+
Then the output should not contain "Faraday: you may want to install system_timer for reliable timeouts"
|
32
|
+
|
33
|
+
#
|
34
|
+
# issue #81, https://github.com/mroth/lolcommits/issues/81
|
35
|
+
#
|
36
|
+
Scenario: don't want to see initialized constant warning from Faraday on CLI (on MRI 1.8.7)
|
37
|
+
When I successfully run `lolcommits`
|
38
|
+
Then the output should not contain "warning: already initialized constant DEFAULT_BOUNDARY"
|
39
|
+
|
40
|
+
#
|
41
|
+
# issue #87, https://github.com/mroth/lolcommits/issues/87
|
42
|
+
#
|
43
|
+
@fake-no-imagemagick
|
44
|
+
Scenario: gracefully fail when imagemagick is not installed
|
45
|
+
When I run `lolcommits`
|
46
|
+
Then the output should contain "ImageMagick does not appear to be properly installed"
|
47
|
+
And the exit status should be 1
|
48
|
+
|
49
|
+
#
|
50
|
+
# issue #50, https://github.com/mroth/lolcommits/issues/50
|
51
|
+
#
|
52
|
+
Scenario: catch upstream bug with ruby-git and color=always
|
53
|
+
Given I am in a git repository named "whatev" with lolcommits enabled
|
54
|
+
And I successfully run `git config color.ui always`
|
55
|
+
When I run `lolcommits`
|
56
|
+
Then the output should contain "Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'."
|
57
|
+
And the output should contain "Try setting it to 'auto' instead!"
|
58
|
+
And the exit status should be 1
|
@@ -0,0 +1,147 @@
|
|
1
|
+
Feature: Basic UI functionality
|
2
|
+
|
3
|
+
Scenario: App just runs
|
4
|
+
When I get help for "lolcommits"
|
5
|
+
Then the exit status should be 0
|
6
|
+
And the banner should be present
|
7
|
+
|
8
|
+
Scenario: Enable in a naked git repository
|
9
|
+
Given a git repository named "loltest" with no "post-commit" hook
|
10
|
+
When I cd to "loltest"
|
11
|
+
And I successfully run `lolcommits --enable`
|
12
|
+
Then the output should contain "installed lolcommmit hook as:"
|
13
|
+
And the output should contain "(to remove later, you can use: lolcommits --disable)"
|
14
|
+
And a file named ".git/hooks/post-commit" should exist
|
15
|
+
And the exit status should be 0
|
16
|
+
|
17
|
+
Scenario: Disable in a enabled git repository
|
18
|
+
Given I am in a git repository named "lolenabled" with lolcommits enabled
|
19
|
+
When I successfully run `lolcommits --disable`
|
20
|
+
Then the output should contain "removed"
|
21
|
+
And a file named ".git/hooks/post-commit" should not exist
|
22
|
+
And the exit status should be 0
|
23
|
+
|
24
|
+
Scenario: Trying to enable while not in a git repo fails
|
25
|
+
Given I am in a directory named "svnrulez"
|
26
|
+
When I run `lolcommits --enable`
|
27
|
+
Then the output should contain "You don't appear to be in the base directory of a git project."
|
28
|
+
And the exit status should be 1
|
29
|
+
|
30
|
+
Scenario: Commiting in an enabled repo triggers successful capture
|
31
|
+
Given I am in a git repository named "testcapture" with lolcommits enabled
|
32
|
+
When I do a git commit
|
33
|
+
Then the output should contain "*** Preserving this moment in history."
|
34
|
+
And a directory named "../.lolcommits/testcapture" should exist
|
35
|
+
And a file named "../.lolcommits/testcapture/tmp_snapshot.jpg" should not exist
|
36
|
+
And there should be exactly 1 jpg in "../.lolcommits/testcapture"
|
37
|
+
|
38
|
+
Scenario: Commiting in an enabled repo subdirectory triggers successful capture of parent repo
|
39
|
+
Given I am in a git repository named "testcapture" with lolcommits enabled
|
40
|
+
And a directory named "subdir"
|
41
|
+
And an empty file named "subdir/FOOBAR"
|
42
|
+
When I cd to "subdir/"
|
43
|
+
And I do a git commit
|
44
|
+
Then the output should contain "*** Preserving this moment in history."
|
45
|
+
And a directory named "../../.lolcommits/testcapture" should exist
|
46
|
+
And a directory named "../../.lolcommits/subdir" should not exist
|
47
|
+
And there should be exactly 1 jpg in "../../.lolcommits/testcapture"
|
48
|
+
|
49
|
+
Scenario: Show plugins
|
50
|
+
When I successfully run `lolcommits --plugins`
|
51
|
+
Then the output should contain a list of plugins
|
52
|
+
|
53
|
+
#
|
54
|
+
# a stab at recreating ken's scenarios with native aruba steps, not quite there yet in terms
|
55
|
+
# of elegance, but its passing so might as well leave in for now.
|
56
|
+
#
|
57
|
+
Scenario: Configuring plugin (with native aruba steps)
|
58
|
+
Given a git repository named "config-test"
|
59
|
+
When I cd to "config-test"
|
60
|
+
And I run `lolcommits --config` interactively
|
61
|
+
When I type "loltext"
|
62
|
+
When I type "true"
|
63
|
+
Then the output should contain a list of plugins
|
64
|
+
And the output should contain "Name of plugin to configure:"
|
65
|
+
Then the output should contain "enabled:"
|
66
|
+
Then the output should contain "Successfully Configured"
|
67
|
+
And a file named "../.lolcommits/config-test/config.yml" should exist
|
68
|
+
When I successfully run `lolcommits --show-config`
|
69
|
+
Then the output should contain "loltext:"
|
70
|
+
And the output should contain "enabled: true"
|
71
|
+
|
72
|
+
Scenario: Configuring Plugin
|
73
|
+
Given a git repository named "config-test"
|
74
|
+
When I cd to "config-test"
|
75
|
+
And I run `lolcommits --config` and wait for output
|
76
|
+
When I enter "loltext" for "Name of plugin to configure"
|
77
|
+
And I enter "true" for "enabled"
|
78
|
+
Then I should be presented "Successfully Configured"
|
79
|
+
And a file named "../.lolcommits/config-test/config.yml" should exist
|
80
|
+
When I successfully run `lolcommits --show-config`
|
81
|
+
Then the output should contain "loltext:"
|
82
|
+
And the output should contain "enabled: true"
|
83
|
+
|
84
|
+
Scenario: Configuring Plugin In Test Mode
|
85
|
+
Given a git repository named "testmode-config-test"
|
86
|
+
When I cd to "testmode-config-test"
|
87
|
+
And I run `lolcommits --config --test` and wait for output
|
88
|
+
And I enter "loltext" for "Name of plugin to configure"
|
89
|
+
And I enter "true" for "enabled"
|
90
|
+
Then I should be presented "Successfully Configured"
|
91
|
+
And a file named "../.lolcommits/test/config.yml" should exist
|
92
|
+
When I successfully run `lolcommits --test --show-config`
|
93
|
+
Then the output should contain "loltext:"
|
94
|
+
And the output should contain "enabled: true"
|
95
|
+
|
96
|
+
Scenario: test capture should work regardless of whether in a git repository
|
97
|
+
Given I am in a directory named "nothingtoseehere"
|
98
|
+
When I run `lolcommits --test --capture`
|
99
|
+
Then the output should contain "*** Capturing in test mode."
|
100
|
+
And the output should not contain "path does not exist (ArgumentError)"
|
101
|
+
And the exit status should be 0
|
102
|
+
|
103
|
+
Scenario: test capture should store in its own test directory
|
104
|
+
Given I am in a git repository named "randomgitrepo" with lolcommits enabled
|
105
|
+
When I successfully run `lolcommits --test --capture`
|
106
|
+
Then a directory named "../.lolcommits/test" should exist
|
107
|
+
And a directory named "../.lolcommits/randomgitrepo" should not exist
|
108
|
+
|
109
|
+
Scenario: last command should work properly when in a lolrepo
|
110
|
+
Given a git repository named "randomgitrepo"
|
111
|
+
And a loldir named "randomgitrepo" with 2 lolimages
|
112
|
+
And I cd to "randomgitrepo"
|
113
|
+
When I run `lolcommits --last`
|
114
|
+
Then the exit status should be 0
|
115
|
+
|
116
|
+
Scenario: last command should fail gracefully if not in a lolrepo
|
117
|
+
Given I am in a directory named "gitsuxcvs4eva"
|
118
|
+
When I run `lolcommits --last`
|
119
|
+
Then the output should contain "Can't do that since we're not in a valid git repository!"
|
120
|
+
And the exit status should be 1
|
121
|
+
|
122
|
+
Scenario: last command should fail gracefully if zero lolimages in lolrepo
|
123
|
+
Given a git repository named "randomgitrepo"
|
124
|
+
And a loldir named "randomgitrepo" with 0 lolimages
|
125
|
+
And I cd to "randomgitrepo"
|
126
|
+
When I run `lolcommits --last`
|
127
|
+
Then the output should contain "No lolcommits have been captured for this repository yet."
|
128
|
+
Then the exit status should be 1
|
129
|
+
|
130
|
+
Scenario: browse command should work properly when in a lolrepo
|
131
|
+
Given a git repository named "randomgitrepo"
|
132
|
+
And a loldir named "randomgitrepo" with 2 lolimages
|
133
|
+
And I cd to "randomgitrepo"
|
134
|
+
When I run `lolcommits --browse`
|
135
|
+
Then the exit status should be 0
|
136
|
+
|
137
|
+
Scenario: browse command should fail gracefully when not in a lolrepo
|
138
|
+
Given I am in a directory named "gitsuxcvs4eva"
|
139
|
+
When I run `lolcommits --browse`
|
140
|
+
Then the output should contain "Can't do that since we're not in a valid git repository!"
|
141
|
+
And the exit status should be 1
|
142
|
+
|
143
|
+
Scenario: handle commit messages with quotation marks
|
144
|
+
Given I am in a git repository named "shellz" with lolcommits enabled
|
145
|
+
When I successfully run `git commit --allow-empty -m 'i hate \"air quotes\" dont you'`
|
146
|
+
Then the exit status should be 0
|
147
|
+
And there should be exactly 1 jpg in "../.lolcommits/shellz"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Feature: Plugins Work
|
2
|
+
###
|
3
|
+
#@slow_process
|
4
|
+
#Scenario: Lolcommits.com integration works
|
5
|
+
#Given I am in a git repository named "dot_com" with lolcommits enabled
|
6
|
+
#When I run `lolcommits --config` and wait for output
|
7
|
+
#And I enter "dot_com" for "Plugin Name"
|
8
|
+
#And I enter "true" for "enabled"
|
9
|
+
#And I enter "b2a70ac0b64e012fa61522000a8c42dc" for "api_key"
|
10
|
+
# Then I should be presented "Successfully Configured"
|
11
|
+
# When I do a git commit
|
12
|
+
# Then the output should contain "*** Preserving this moment in history."
|
13
|
+
# And there should be exactly 1 jpg in "../.lolcommits/dot_com"
|
14
|
+
###
|
15
|
+
Scenario: Disable loltext
|
16
|
+
Given I am in a git repository named "loltext" with lolcommits enabled
|
17
|
+
And I run `lolcommits --config` and wait for output
|
18
|
+
And I enter "loltext" for "Plugin Name"
|
19
|
+
And I enter "false" for "enabled"
|
20
|
+
Then I should be presented "Successfully Configured"
|
21
|
+
When I do a git commit
|
22
|
+
Then the output should contain "*** Preserving this moment in history."
|
23
|
+
And there should be exactly 1 jpg in "../.lolcommits/loltext"
|
24
|
+
|
25
|
+
Scenario: lolsrv integration works
|
26
|
+
Given I am in a git repository named "lolsrv" with lolcommits enabled
|
27
|
+
When I run `lolcommits --config` and wait for output
|
28
|
+
And I enter "lolsrv" for "Plugin Name"
|
29
|
+
And I enter "true" for "enabled"
|
30
|
+
And I enter "http://localhost" for "server"
|
31
|
+
Then I should be presented "Successfully Configured"
|
32
|
+
When I do a git commit
|
33
|
+
Then the output should contain "*** Preserving this moment in history."
|
34
|
+
And there should be exactly 1 jpg in "../.lolcommits/lolsrv"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
include FileUtils
|
2
|
+
|
3
|
+
Given /^I am in a directory named "(.*?)"$/ do |dir_name|
|
4
|
+
steps %Q{
|
5
|
+
Given a directory named "#{dir_name}"
|
6
|
+
And I cd to "#{dir_name}"
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
Given /^a git repository named "(.*?)"$/ do |repo_name|
|
11
|
+
repo_dir = File.join current_dir, repo_name
|
12
|
+
mkdir_p repo_dir
|
13
|
+
Dir.chdir repo_dir do
|
14
|
+
sh "git init --quiet ."
|
15
|
+
sh "git config user.name 'Testy McTesterson'"
|
16
|
+
sh "git config user.email 'testy@tester.com'"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Given /^the git repository named "(.*?)" has no "(.*?)" hook$/ do |repo_name, hook_name|
|
21
|
+
hook_file = File.join current_dir, repo_name, ".git", "hooks", hook_name
|
22
|
+
delete(hook_file) if File.exists? hook_file
|
23
|
+
end
|
24
|
+
|
25
|
+
Given /^the git repository named "(.*?)" has a "(.*?)" hook$/ do |repo_name, hook_name|
|
26
|
+
hook_file = File.join current_dir, repo_name, ".git", "hooks", hook_name
|
27
|
+
touch(hook_file) if not File.exists? hook_file
|
28
|
+
end
|
29
|
+
|
30
|
+
Given /^a git repository named "(.*?)" with (a|no) "(.*?)" hook$/ do |repo_name, yesno_modifier, hook_name|
|
31
|
+
step %{a git repository named "#{repo_name}"}
|
32
|
+
step %{the git repository named "#{repo_name}" has #{yesno_modifier} "#{hook_name}" hook}
|
33
|
+
end
|
34
|
+
|
35
|
+
Given /^I am in a git repository named "(.*?)" with lolcommits enabled$/ do |repo_name|
|
36
|
+
steps %Q{
|
37
|
+
Given a git repository named "#{repo_name}"
|
38
|
+
And I cd to "#{repo_name}"
|
39
|
+
And I successfully run `lolcommits --enable`
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
When /^I run `(.*?)` and wait for output$/ do |command|
|
44
|
+
command = "cd #{current_dir} && #{command}"
|
45
|
+
@stdin, @stdout, @stderr = Open3.popen3(command)
|
46
|
+
@fields = Hash.new
|
47
|
+
end
|
48
|
+
|
49
|
+
Given /^a loldir named "(.*?)" with (\d+) lolimages$/ do |repo_name, num_images|
|
50
|
+
loldir = "tmp/aruba/.lolcommits/#{repo_name}"
|
51
|
+
mkdir_p loldir
|
52
|
+
num_images.to_i.times do
|
53
|
+
random_hex = "%011x" % (rand * 0xfffffffffff)
|
54
|
+
cp "test/images/test_image.jpg", File.join( loldir, "#{random_hex}.jpg")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Then /^I should be (prompted for|presented) "(.*?)"$/ do |_, prompt|
|
59
|
+
assert @stdout.read.to_s.include?(prompt)
|
60
|
+
end
|
61
|
+
|
62
|
+
When /^I enter "(.*?)" for "(.*?)"$/ do |input, field|
|
63
|
+
@fields[field] = input
|
64
|
+
@stdin.puts input
|
65
|
+
end
|
66
|
+
|
67
|
+
Then /^there should be (?:exactly|only) (.*?) jpg(?:s?) in "(.*?)"$/ do |n, folder|
|
68
|
+
assert_equal n.to_i, Dir["#{current_dir}/#{folder}/*.jpg"].count
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^the output should contain a list of plugins$/ do
|
72
|
+
step %{the output should contain "Available plugins: "}
|
73
|
+
end
|
74
|
+
|
75
|
+
When /^I do a git commit with commit message "(.*?)"$/ do |commit_msg|
|
76
|
+
filename = Faker::Lorem.words(1).first
|
77
|
+
step %{a 98 byte file named "#{filename}"}
|
78
|
+
step %{I successfully run `git add #{filename}`}
|
79
|
+
step %{I successfully run `git commit -m "#{commit_msg}"`}
|
80
|
+
end
|
81
|
+
|
82
|
+
When /^I do a git commit$/ do
|
83
|
+
commit_msg = Faker::Lorem.sentence
|
84
|
+
step %{I do a git commit with commit message "#{commit_msg}"}
|
85
|
+
end
|
86
|
+
|
87
|
+
When /^I do (\d+) git commits$/ do |n|
|
88
|
+
n.to_i.times do
|
89
|
+
step %{I do a git commit}
|
90
|
+
sleep 0.1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^there should be (\d+) commit entries in the git log$/ do |n|
|
95
|
+
sleep 1 #let the file writing catch up
|
96
|
+
assert_equal n.to_i, `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
|
97
|
+
end
|
98
|
+
|