lolcommits 0.17.3 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,236 +0,0 @@
1
- require 'fileutils'
2
- require 'aruba/api'
3
-
4
- def postcommit_hook_git
5
- '.git/hooks/post-commit'
6
- end
7
-
8
- def postcommit_hook_mercurial
9
- '.hg/hgrc'
10
- end
11
-
12
- def default_repo
13
- 'myrepo'
14
- end
15
-
16
- def default_loldir
17
- "~/.lolcommits/#{default_repo}"
18
- end
19
-
20
- Given(/^I am in a directory named "(.*?)"$/) do |dir_name|
21
- steps %(
22
- Given a directory named "#{dir_name}"
23
- And I cd to "#{dir_name}"
24
- )
25
- end
26
-
27
- Given(/^a git repo named "(.*?)"$/) do |repo_name|
28
- steps %(
29
- Given I run `git init --quiet "#{repo_name}"`
30
- )
31
- end
32
-
33
- Given(/^I am in a git repo named "(.*?)"$/) do |repo|
34
- steps %(
35
- Given a git repo named "#{repo}"
36
- And I cd to "#{repo}"
37
- )
38
- end
39
-
40
- Given(/^I am in a git repo$/) do
41
- steps %(
42
- Given I am in a git repo named "#{default_repo}"
43
- )
44
- end
45
-
46
- Given(/^I am not in a git repo/) do
47
- steps %(
48
- Given I cd to "/tmp"
49
- And a directory named "lolcommits_no_repo"
50
- And I cd to "lolcommits_no_repo"
51
- )
52
- end
53
-
54
- Given(/^I am in a git repo named "(.*?)" with lolcommits enabled$/) do |repo|
55
- steps %(
56
- Given I am in a git repo named "#{repo}"
57
- And I run `lolcommits --enable`
58
- )
59
- end
60
-
61
- Given(/^I am in a git repo with lolcommits enabled$/) do
62
- steps %(
63
- Given I am in a git repo named "#{default_repo}" with lolcommits enabled
64
- )
65
- end
66
-
67
- Given(/^a git post-commit hook with "(.*?)"$/) do |file_content|
68
- steps %(
69
- Given a file named "#{postcommit_hook_git}" with:
70
- """
71
- #{file_content}
72
- """
73
- )
74
- end
75
-
76
- Then(/^the lolcommits git post-commit hook should be properly installed$/) do
77
- steps %(
78
- Then the git post-commit hook should contain "lolcommits --capture"
79
- )
80
- end
81
-
82
- Then(/^the git post-commit hook (should|should not) contain "(.*?)"$/) do |should, content|
83
- steps %(
84
- Then the file "#{postcommit_hook_git}" #{should} contain "#{content}"
85
- )
86
- end
87
-
88
- Given(/^a mercurial repo named "(.*?)"$/) do |repo_name|
89
- steps %(
90
- Given I run `hg init "#{repo_name}"`
91
- )
92
- end
93
-
94
- Given(/^I am in a mercurial repo named "(.*?)"$/) do |repo|
95
- steps %(
96
- Given a mercurial repo named "#{repo}"
97
- And I cd to "#{repo}"
98
- )
99
- end
100
-
101
- Given(/^I am in a mercurial repo$/) do
102
- steps %(
103
- Given I am in a mercurial repo named "#{default_repo}"
104
- )
105
- end
106
-
107
- Given(/^I am in a mercurial repo named "(.*?)" with lolcommits enabled$/) do |repo|
108
- steps %(
109
- Given I am in a mercurial repo named "#{repo}"
110
- And I run `lolcommits --enable`
111
- )
112
- end
113
-
114
- Given(/^I am in a mercurial repo with lolcommits enabled$/) do
115
- steps %(
116
- Given I am in a mercurial repo named "#{default_repo}" with lolcommits enabled
117
- )
118
- end
119
-
120
- Given(/^a mercurial post-commit hook with "(.*?)"$/) do |file_content|
121
- steps %(
122
- Given a file named "#{postcommit_hook_mercurial}" with:
123
- """
124
- #{file_content}
125
- """
126
- )
127
- end
128
-
129
- Then(/^the lolcommits mercurial post-commit hook should be properly installed$/) do
130
- steps %(
131
- Then the mercurial post-commit hook should contain "lolcommits --capture"
132
- )
133
- end
134
-
135
- Then(/^the mercurial post-commit hook (should|should not) contain "(.*?)"$/) do |should, content|
136
- steps %(
137
- Then the file "#{postcommit_hook_mercurial}" #{should} contain "#{content}"
138
- )
139
- end
140
-
141
- Given(/^I have environment variable (.*?) set to (.*?)$/) do |var, value|
142
- set_environment_variable var, value
143
- end
144
-
145
- Given(/^its loldir has (\d+) lolimages$/) do |num_images|
146
- steps %(
147
- Given a loldir named "#{default_repo}" with #{num_images} lolimages
148
- )
149
- end
150
-
151
- Given(/^a loldir named "(.*?)" with (\d+) lolimages$/) do |repo, num_images|
152
- loldir = expand_path("~/.lolcommits/#{repo}")
153
- FileUtils.mkdir_p loldir
154
- num_images.to_i.times do
155
- sha = format('%<hex>x', hex: (rand * 0xfffffffffff))
156
- FileUtils.cp 'test/assets/test_image.jpg', File.join(loldir, "#{sha}.jpg")
157
- end
158
- end
159
-
160
- Then(/^there should be exactly (.*?) (mp4|jpg|gif|pid)s? in its loldir$/) do |n, type|
161
- steps %(
162
- Then there should be exactly #{n} #{type} in "#{default_loldir}"
163
- )
164
- end
165
-
166
- Then(/^there should be exactly (.*?) (mp4|jpg|gif|pid)s? in "(.*?)"$/) do |n, type, folder|
167
- expect(Dir[expand_path("#{folder}/*.#{type}")].count).to eq(n.to_i)
168
- end
169
-
170
- Then(/^the output should contain a list of plugins$/) do
171
- step %(the output should contain "Installed plugins: (* enabled)")
172
- step %(the output should contain "[*] loltext")
173
- end
174
-
175
- Then(/^the output should show the version number$/) do
176
- step %(the output should match /^#{Lolcommits::VERSION}$/)
177
- end
178
-
179
- When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg|
180
- filename = FFaker::Lorem.words(1).first
181
- steps %(
182
- Given a 98 byte file named "#{filename}"
183
- And I run `git add #{filename}`
184
- And I run `git commit -m "#{commit_msg}"`
185
- )
186
- end
187
-
188
- When(/^I do a git commit$/) do
189
- step %(I do a git commit with commit message "#{FFaker::Lorem.sentence}")
190
- end
191
-
192
- When(/^I do (\d+) git commits$/) do |n|
193
- n.to_i.times do
194
- step %(I do a git commit)
195
- sleep 0.2
196
- end
197
- end
198
-
199
- Then(/^there should be (\d+) commit entries in the git log$/) do |n|
200
- sleep 1 # let the file writing catch up
201
- expect(n.to_i).to eq `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
202
- end
203
-
204
- When(/^I do a mercurial commit with commit message "(.*?)"$/) do |commit_msg|
205
- filename = FFaker::Lorem.words(1).first
206
- steps %(
207
- Given a 98 byte file named "#{filename}"
208
- And I run `hg add #{filename}`
209
- And I run `hg commit -m "#{commit_msg}"`
210
- )
211
- end
212
-
213
- When(/^I do a mercurial commit$/) do
214
- step %(I do a mercurial commit with commit message "#{FFaker::Lorem.sentence}")
215
- end
216
-
217
- When(/^I do (\d+) mercurial commits$/) do |n|
218
- n.to_i.times do
219
- step %(I do a mercurial commit)
220
- sleep 0.1
221
- end
222
- end
223
-
224
- Then(/^there should be (\d+) commit entries in the mercurial log$/) do |n|
225
- sleep 1 # let the file writing catch up
226
- expect(n.to_i).to eq `hg log | grep '^changeset:' | wc -l`.chomp.to_i
227
- end
228
-
229
- Given(/^I am using a "(.*?)" platform$/) do |host_os_name|
230
- set_environment_variable 'LOLCOMMITS_FAKE_HOST_OS', host_os_name
231
- end
232
-
233
- When(/^I wait for the child process to exit in "(.*?)"$/) do |repo_name|
234
- pid_loc = expand_path("~/.lolcommits/#{repo_name}/lolcommits.pid")
235
- sleep 0.1 while File.exist?(pid_loc)
236
- end
@@ -1,54 +0,0 @@
1
- require 'aruba/cucumber'
2
- require 'optparse_plus/cucumber'
3
- require 'open3'
4
- require 'ffaker'
5
- require 'fileutils'
6
-
7
- require File.join(__dir__, 'path_helpers')
8
- include Lolcommits
9
-
10
- World(PathHelpers)
11
-
12
- Aruba.configure do |config|
13
- config.exit_timeout = 20
14
- # allow absolute paths for tests involving no repo
15
- config.allow_absolute_paths = true
16
- end
17
-
18
- Before do
19
- # prevent launchy from opening gifs in tests
20
- set_environment_variable 'LAUNCHY_DRY_RUN', 'true'
21
- set_environment_variable 'LOLCOMMITS_CAPTURER', 'Lolcommits::CaptureFake'
22
-
23
- author_name = 'Testy McTesterson'
24
- author_email = 'testy@tester.com'
25
-
26
- set_environment_variable 'GIT_AUTHOR_NAME', author_name
27
- set_environment_variable 'GIT_COMMITTER_NAME', author_name
28
- set_environment_variable 'GIT_AUTHOR_EMAIL', author_email
29
- set_environment_variable 'GIT_COMMITTER_EMAIL', author_email
30
- end
31
-
32
- # for tasks that may take an incredibly long time (e.g. network related)
33
- # we should strive to not have any of these in our scenarios, naturally.
34
- Before('@slow_process') do
35
- Aruba.configure do |config|
36
- config.exit_timeout = 60
37
- end
38
- end
39
-
40
- # in order to fake an interactive rebase, we replace the editor with a script
41
- # to simply squash a few random commits. in this case, using lines 3-5.
42
- Before('@fake-interactive-rebase') do
43
- set_environment_variable 'GIT_EDITOR', "sed -i -e '3,5 s/pick/squash/g'"
44
- end
45
-
46
- # adjust the path so tests dont see a global imagemagick install
47
- Before('@fake-no-imagemagick') do
48
- reject_paths_with_cmd('magick')
49
- end
50
-
51
- # adjust the path so tests dont see a global ffmpeg install
52
- Before('@fake-no-ffmpeg') do
53
- reject_paths_with_cmd('ffmpeg')
54
- end
@@ -1,36 +0,0 @@
1
- require 'fileutils'
2
- require 'aruba/api'
3
- require 'lolcommits/platform'
4
-
5
- module PathHelpers
6
- def reject_paths_with_cmd(cmd)
7
- # make a new subdir that still contains cmds
8
- tmpbindir = expand_path('./bin')
9
- FileUtils.mkdir_p tmpbindir
10
-
11
- preseve_cmds_in_path(%w[git mplayer], tmpbindir)
12
-
13
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [ '' ]
14
- newpaths = ENV['PATH'].split(File::PATH_SEPARATOR).reject do |path|
15
- found_cmd = false
16
- exts.each do |ext|
17
- exe = "#{path}/#{cmd}#{ext}"
18
- found_cmd = true if File.executable? exe
19
- end
20
- found_cmd
21
- end
22
-
23
- # add the temporary directory with git in it back into the path
24
- newpaths << tmpbindir
25
-
26
- # use aruba/api set_environment_variable to set PATH, which will be automaticaly restored
27
- set_environment_variable 'PATH', newpaths.join(File::PATH_SEPARATOR)
28
- end
29
-
30
- def preseve_cmds_in_path(cmds, tmpbindir)
31
- cmds.each do |cmd|
32
- whichcmd = Lolcommits::Platform.command_which(cmd)
33
- FileUtils.ln_s whichcmd, File.join(tmpbindir, File.basename(whichcmd)) unless whichcmd.nil?
34
- end
35
- end
36
- end
data/lolcommits.gemspec DELETED
@@ -1,61 +0,0 @@
1
- require_relative 'lib/lolcommits/version'
2
-
3
- Gem::Specification.new do |s|
4
- s.name = Lolcommits::GEM_NAME.dup
5
- s.version = Lolcommits::VERSION.dup
6
-
7
- s.authors = [ 'Matthew Rothenberg', 'Matthew Hutchinson' ]
8
- s.email = [ 'mrothenberg@gmail.com', 'matt@hiddenloop.com' ]
9
- s.license = 'LGPL-3.0'
10
- s.summary = 'Capture webcam image on git commit for lulz.'
11
-
12
- s.description = <<-DESC
13
- lolcommits takes a snapshot with your webcam every time you git commit code,
14
- and archives a lolcat style image with it. It's selfies for software
15
- developers. `git blame` has never been so much fun.
16
- DESC
17
-
18
- s.metadata = {
19
- 'homepage_uri' => 'https://lolcommits.github.io',
20
- 'source_code_uri' => 'https://github.com/lolcommits/lolcommits',
21
- 'changelog_uri' => 'https://github.com/lolcommits/lolcommits/blob/master/CHANGELOG.md',
22
- 'bug_tracker_uri' => 'https://github.com/lolcommits/lolcommits/issues',
23
- 'allowed_push_host' => 'https://rubygems.org',
24
- 'rubygems_mfa_required' => 'true'
25
- }
26
-
27
- s.files = `git ls-files`.split("\n")
28
- s.executables = 'lolcommits'
29
- s.require_paths = [ 'lib' ]
30
-
31
- # non-gem dependencies
32
- s.required_ruby_version = '>= 3.1'
33
- s.requirements << 'imagemagick'
34
- s.requirements << 'a webcam'
35
-
36
- # core
37
- s.add_dependency('base64')
38
- s.add_dependency('git', '~> 2.3.3')
39
- s.add_dependency('launchy', '~> 3.0.1')
40
- s.add_dependency('logger')
41
- s.add_dependency('mercurial-ruby', '~> 0.7.12')
42
- s.add_dependency('mini_magick', '~> 5.0.1')
43
- s.add_dependency('open4', '~> 1.3.4')
44
- s.add_dependency('optparse-plus', '~> 3.0.1')
45
- s.add_dependency('ostruct')
46
-
47
- # included plugins
48
- s.add_dependency('lolcommits-loltext', '~> 0.5.0')
49
-
50
- # rubocop
51
- s.add_dependency('rubocop')
52
- s.add_dependency('rubocop-performance')
53
-
54
- # development & test gems
55
- s.add_development_dependency('aruba')
56
- s.add_development_dependency('debug')
57
- s.add_development_dependency('ffaker')
58
- s.add_development_dependency('minitest')
59
- s.add_development_dependency('rake')
60
- s.add_development_dependency('rdoc')
61
- end
Binary file
Binary file
Binary file
@@ -1,17 +0,0 @@
1
- require "test_helper"
2
-
3
- class PermissionsTest < Minitest::Test
4
- #
5
- # issue #53, https://github.com/lolcommits/lolcommits/issues/53
6
- # this will test the permissions but only locally, important before building a gem package!
7
- #
8
- def test_permissions
9
- imagesnap_perms = File.lstat(File.join(Lolcommits::Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "imagesnap", "imagesnap")).mode & 0o777
10
- videosnap_perms = File.lstat(File.join(Lolcommits::Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "videosnap", "videosnap")).mode & 0o777
11
- commandcam_perms = File.lstat(File.join(Lolcommits::Configuration::LOLCOMMITS_ROOT, "vendor", "ext", "CommandCam", "CommandCam.exe")).mode & 0o777
12
-
13
- assert [ 0o755, 0o775 ].include?(imagesnap_perms), "expected perms of 755/775 but instead got #{format '%<perms>o', perms: imagesnap_perms}"
14
- assert [ 0o755, 0o775 ].include?(videosnap_perms), "expected perms of 755/775 but instead got #{format '%<perms>o', perms: videosnap_perms}"
15
- assert [ 0o755, 0o775 ].include?(commandcam_perms), "expected perms of 755/775 but instead got #{format '%<perms>o', perms: commandcam_perms}"
16
- end
17
- end
data/test/test_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- require "minitest/autorun"
2
- require "lolcommits"