gitfog 0.0.2
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 +7 -0
- data/bin/gitfog +311 -0
- data/lib/gitfog.rb +6 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f3ea0fda38a314d83cd471b96422c8f3068723b
|
4
|
+
data.tar.gz: a06c61e02bd8b13916d78a9bb2e572e8516a1546
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 696d0b097b30d4529d1dca55686b759466c01f28515dc1b478fbe79a057050800cb41e64820691394ab7ef5615e187998357dcbd6863e2da4242582e358eb4d6
|
7
|
+
data.tar.gz: 195f79230bfa7dee63ffae0bd66dc10c06804505c440232a3912efa7609b08ed94ac41d523a33137c9c4ae6a3fd972fc74da3a89ab967921df0bad5787fc3301
|
data/bin/gitfog
ADDED
@@ -0,0 +1,311 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# GitFog
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'commander/import'
|
6
|
+
require 'highline/import'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'git'
|
9
|
+
|
10
|
+
program :version, '0.0.2'
|
11
|
+
program :description, 'Camouflage git commit and push'
|
12
|
+
|
13
|
+
def verify_gitfog
|
14
|
+
unless File.directory?('.gitfog')
|
15
|
+
puts '.gitfog not found: run gitfog in the top level of an init-ed gitfog repo.'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def update_gitfog
|
21
|
+
# remove any existing .gitfog, update from .git
|
22
|
+
unless File.directory?('.git')
|
23
|
+
puts "no .git directory available to copy to .gitfog"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
if File.directory?('.gitfog')
|
27
|
+
FileUtils.rm_rf('.gitfog')
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
# make new .gitfog
|
32
|
+
FileUtils.copy_entry('.git', '.gitfog', preserve: true, remove_destination: true)
|
33
|
+
|
34
|
+
# remove old .git directory
|
35
|
+
FileUtils.rm_rf('.git')
|
36
|
+
rescue
|
37
|
+
puts "did not finish copying .git back to .gitfog"
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def restore_git
|
43
|
+
# copy .gitfog directory to .git
|
44
|
+
verify_gitfog
|
45
|
+
if File.directory?('.git')
|
46
|
+
FileUtils.rm_rf('.git')
|
47
|
+
end
|
48
|
+
FileUtils.copy_entry('.gitfog', '.git', preserve: true, remove_destination: true)
|
49
|
+
end
|
50
|
+
|
51
|
+
command :init do |c|
|
52
|
+
c.syntax = 'gitfog init'
|
53
|
+
c.summary = 'Disable git and enable gitfog commands.'
|
54
|
+
c.description = 'This enables gitfog commands and prevents you from using the regular git commands by habit. You will be asked to set a user email and password to use in your commits.'
|
55
|
+
c.action do |args, options|
|
56
|
+
# check if .gitfog already exists
|
57
|
+
if File.directory?('.gitfog')
|
58
|
+
puts ".gitfog already exists: run 'gitfog off' to reset."
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
|
62
|
+
# check if .git exists
|
63
|
+
unless File.directory?('.git')
|
64
|
+
puts '.git not found: run gitfog in the top level of an init-ed git repo.'
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
|
68
|
+
# check if .gitignore exists
|
69
|
+
if File.exist?('.gitignore')
|
70
|
+
has_gitignore = false
|
71
|
+
has_gitfog = false
|
72
|
+
ignored = IO.readlines('.gitignore').map do |line|
|
73
|
+
has_gitignore = true if line.strip == '.gitignore'
|
74
|
+
has_gitfog = true if line.strip == '.gitfog'
|
75
|
+
line
|
76
|
+
end
|
77
|
+
unless has_gitfog
|
78
|
+
ignored << "\n.gitfog\n"
|
79
|
+
puts "Added .gitfog to the .gitignore file"
|
80
|
+
end
|
81
|
+
unless has_gitignore
|
82
|
+
ignored << "\n.gitignore\n"
|
83
|
+
puts "Added .gitignore to the .gitignore file"
|
84
|
+
end
|
85
|
+
# output modified .gitignore
|
86
|
+
File.open('.gitignore', 'w') do |ifile|
|
87
|
+
ifile.puts ignored
|
88
|
+
end
|
89
|
+
else
|
90
|
+
# create .gitignore
|
91
|
+
puts 'Creating a .gitignore file to hide some files from git'
|
92
|
+
File.open('.gitignore', 'w') do |file|
|
93
|
+
file.puts ".gitfog\n.gitignore\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# set user and email
|
98
|
+
set_user = ask 'Show what name on git? '
|
99
|
+
set_mail = ask 'Show what email on git? '
|
100
|
+
# open old .git/config
|
101
|
+
config = IO.readlines('.git/config').map do |line|
|
102
|
+
if line.index('email') != nil
|
103
|
+
"\temail = " + set_mail
|
104
|
+
elsif line.index('name') != nil
|
105
|
+
"\tname = " + set_user
|
106
|
+
else
|
107
|
+
line
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# copy .git to .gitfog
|
112
|
+
update_gitfog
|
113
|
+
unless File.directory?('.gitfog')
|
114
|
+
puts "Copy from .git to .gitfog failed"
|
115
|
+
exit
|
116
|
+
end
|
117
|
+
|
118
|
+
# write new .gitfog/config
|
119
|
+
File.open('.gitfog/config', 'w') do |cfile|
|
120
|
+
cfile.puts config
|
121
|
+
end
|
122
|
+
|
123
|
+
# remove old .git directory
|
124
|
+
FileUtils.rm_rf('.git')
|
125
|
+
puts "When you want to restore regular git commands, run 'gitfog off'."
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
command :off do |c|
|
130
|
+
c.syntax = 'gitfog off'
|
131
|
+
c.summary = 'Restore git and disable gitfog commands.'
|
132
|
+
c.description = 'Restore git and disable gitfog commands.'
|
133
|
+
c.action do |args, options|
|
134
|
+
# verify .gitfog exists
|
135
|
+
verify_gitfog
|
136
|
+
|
137
|
+
# copy .gitfog back to .git
|
138
|
+
restore_git
|
139
|
+
|
140
|
+
# remove .gitfog
|
141
|
+
FileUtils.rm_rf('.gitfog')
|
142
|
+
puts "Thanks for using GitFog! You can resume using GitFog with 'gitfog init'"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
command :status do |c|
|
147
|
+
c.syntax = 'gitfog status [options]'
|
148
|
+
c.summary = 'Replaces git status.'
|
149
|
+
c.action do |args, options|
|
150
|
+
# verify .gitfog exists
|
151
|
+
verify_gitfog
|
152
|
+
|
153
|
+
# copy .gitfog directory to .git
|
154
|
+
restore_git
|
155
|
+
|
156
|
+
# run git status with given args
|
157
|
+
system 'git status ' + args.join(' ')
|
158
|
+
|
159
|
+
# remove old .git directory
|
160
|
+
FileUtils.rm_rf('.git')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
command :add do |c|
|
165
|
+
c.syntax = 'gitfog add [options]'
|
166
|
+
c.summary = 'Replaces git add.'
|
167
|
+
c.action do |args, options|
|
168
|
+
# verify .gitfog exists
|
169
|
+
verify_gitfog
|
170
|
+
|
171
|
+
# copy .gitfog directory to .git
|
172
|
+
restore_git
|
173
|
+
|
174
|
+
# run git add with given args
|
175
|
+
system 'git add ' + args.join(' ')
|
176
|
+
|
177
|
+
# move .git directory over .gitfog
|
178
|
+
update_gitfog
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
command :rm do |c|
|
183
|
+
c.syntax = 'gitfog rm [options]'
|
184
|
+
c.summary = 'Replaces git rm.'
|
185
|
+
c.action do |args, options|
|
186
|
+
# verify .gitfog exists
|
187
|
+
verify_gitfog
|
188
|
+
|
189
|
+
# copy .gitfog directory to .git
|
190
|
+
restore_git
|
191
|
+
|
192
|
+
# run git rm with given args
|
193
|
+
system 'git rm ' + args.join(' ')
|
194
|
+
|
195
|
+
# copy .git directory over .gitfog
|
196
|
+
update_gitfog
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
command :commit do |c|
|
201
|
+
c.syntax = 'gitfog commit [options]'
|
202
|
+
c.summary = 'Make a commit with a randomized timestamp'
|
203
|
+
c.description = 'Makes the commit with a timestamp between the last commit and now (up to 48 hours ago)'
|
204
|
+
c.option '-m STRING', String, 'Public commit message'
|
205
|
+
c.option '--now', 'Make the commit timestamp happen now'
|
206
|
+
c.action do |args, options|
|
207
|
+
# verify .gitfog exists
|
208
|
+
verify_gitfog
|
209
|
+
|
210
|
+
# copy .gitfog directory to .git
|
211
|
+
restore_git
|
212
|
+
|
213
|
+
unless options.now
|
214
|
+
# find the last commit time
|
215
|
+
repo = Git.open './'
|
216
|
+
last_commit = Time.now - 48 * 60 * 60
|
217
|
+
begin
|
218
|
+
repo.log(1).each do |commit|
|
219
|
+
# actually returns a Time object
|
220
|
+
last_commit = commit.date
|
221
|
+
end
|
222
|
+
rescue
|
223
|
+
# usually means a repo has no prior commits
|
224
|
+
end
|
225
|
+
|
226
|
+
# warn if last commit was recent
|
227
|
+
ok_to_commit = true
|
228
|
+
seconds_diff = Time.now - last_commit
|
229
|
+
if seconds_diff < 60 * 60
|
230
|
+
if seconds_diff < 10 * 60
|
231
|
+
puts "Last commit timestamp was within the last 10 minutes."
|
232
|
+
else
|
233
|
+
puts "Last commit timestamp was within the last hour."
|
234
|
+
end
|
235
|
+
|
236
|
+
# get user approval
|
237
|
+
puts "Continue with less randomized commit time?"
|
238
|
+
ok_to_commit = false
|
239
|
+
commit_input = ask 'Enter Y or Yes to confirm; anything else will cancel commit '
|
240
|
+
if commit_input.strip.downcase == "y" || commit_input.strip.downcase == "yes"
|
241
|
+
ok_to_commit = true
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
if ok_to_commit
|
246
|
+
# choose a past time
|
247
|
+
seconds_diff = Time.now - last_commit
|
248
|
+
commit_time = last_commit + Random.rand(0..seconds_diff)
|
249
|
+
commit_time = commit_time.to_s
|
250
|
+
puts "Backdating to the commit to " + commit_time
|
251
|
+
|
252
|
+
# make a timed commit
|
253
|
+
if options.m
|
254
|
+
system "GIT_AUTHOR_DATE='" + commit_time + "' GIT_COMMITTER_DATE='" + commit_time + "' git commit -m \"" + options.m + "\""
|
255
|
+
else
|
256
|
+
system "GIT_AUTHOR_DATE='" + commit_time + "' GIT_COMMITTER_DATE='" + commit_time + "' git commit"
|
257
|
+
end
|
258
|
+
else
|
259
|
+
puts "Try again after more time has passed."
|
260
|
+
end
|
261
|
+
else
|
262
|
+
puts "Making the commit with local system time"
|
263
|
+
# make a commit without changing time
|
264
|
+
if options.m
|
265
|
+
system 'git commit -m "' + options.m + '"'
|
266
|
+
else
|
267
|
+
system 'git commit'
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
# copy .git directory over .gitfog
|
272
|
+
update_gitfog
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
command :push do |c|
|
277
|
+
c.syntax = 'gitfog push [options]'
|
278
|
+
c.summary = 'Make a push at a random time in the next 8 hours'
|
279
|
+
c.description = 'Make a push at a random time in the next several hours'
|
280
|
+
c.option '--max N', Integer, 'Specify the maximum time to wait'
|
281
|
+
c.option '--now', 'Make the push happen now'
|
282
|
+
|
283
|
+
c.action do |args, options|
|
284
|
+
# verify .gitfog exists
|
285
|
+
verify_gitfog
|
286
|
+
|
287
|
+
# determine time to delay
|
288
|
+
unless options.now
|
289
|
+
# randomized delay time
|
290
|
+
delay_push = 8 * 60 * 60
|
291
|
+
if options.limit
|
292
|
+
# get maximum delay from user
|
293
|
+
delay_push = options.limit * 60 * 60
|
294
|
+
end
|
295
|
+
delay_push = Random.rand(0..delay_push)
|
296
|
+
push_time = Time.now + delay_push
|
297
|
+
puts "Delaying push " + delay_push.to_s + " seconds, until " + push_time.to_s
|
298
|
+
|
299
|
+
sleep delay_push
|
300
|
+
end
|
301
|
+
|
302
|
+
# restore .git
|
303
|
+
restore_git
|
304
|
+
|
305
|
+
# do the push
|
306
|
+
system "git push " + args.join(' ')
|
307
|
+
|
308
|
+
# move .git over .gitfog
|
309
|
+
update_gitfog
|
310
|
+
end
|
311
|
+
end
|
data/lib/gitfog.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitfog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Msjoinder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: highline
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.20
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.20
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fileutils
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: git
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.2.6
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.2.6
|
69
|
+
description: Camouflage git commit and push times, disable regular git commands
|
70
|
+
email: msjoinder@gmail.com
|
71
|
+
executables:
|
72
|
+
- gitfog
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- bin/gitfog
|
77
|
+
- lib/gitfog.rb
|
78
|
+
homepage: https://github.com/msjoinder/gitfog
|
79
|
+
licenses:
|
80
|
+
- GPLv3+
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.2.1
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Camouflage git commit and push times
|
102
|
+
test_files: []
|