not_too_late 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/Rakefile +6 -0
- data/bin/ntl +70 -0
- data/lib/not_too_late.rb +27 -0
- data/lib/not_too_late/cli.rb +5 -0
- data/lib/not_too_late/command.rb +28 -0
- data/lib/not_too_late/config.rb +34 -0
- data/lib/not_too_late/version.rb +3 -0
- data/not_too_late.gemspec +33 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22a21454c9ae438dec04b170d79f32a131de9a9d
|
4
|
+
data.tar.gz: 6d8abfe18bb858d65bf3c2ae15775459c720f6c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5fd4d5b513f00b2fc053b0ac7f2af49441be7e23df1a40f670587fa8a31655d8fec56cb4c8352eff21d1bc7066c9043798ca0ac792999ee99bdb6797151b4c5
|
7
|
+
data.tar.gz: c944d73d2837dbcf83e56801c89fa17746d934f668cb199e26b105521c37505b12f4be0e12c84bb9b4ed72be485b26c22d894da0f848b9edfb5fad121c29a653
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 marwei
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# NotTooLate
|
2
|
+
|
3
|
+
This gem is inspired by [Gitfiti](https://github.com/gelstudios/gitfiti), a github history calendar graffiti tool. However, rather than creating noise commits, NotTooLate lets you spread actual commits over the history.
|
4
|
+
|
5
|
+
If you are an awesome coder but a late starter on github, or if you have been doing so much private development that your public feed is drawing a blank, this gem is for you.
|
6
|
+
|
7
|
+
What does it do? Simple, you work on new projects as always, but instead of running straight git commands, you prefix it with "ntl" (not too late) like this:
|
8
|
+
|
9
|
+
`$ ntl git commit -am "this is not too late" `
|
10
|
+
|
11
|
+
Voila, you've traveled back in time and made a commit.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'not_too_late'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install not_too_late
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Caveat: Although git doesn't complain about messed-up commit timestamps, it is not recommended to use this gem on existing projects that have prior commits. It is also not a good idea to use this gem for multi-contributor projects unless all contributors use this gem with the same configuration.
|
30
|
+
|
31
|
+
### Setup
|
32
|
+
|
33
|
+
Initialize git repo
|
34
|
+
|
35
|
+
$ git init .
|
36
|
+
|
37
|
+
Initialize ntl configuration
|
38
|
+
|
39
|
+
$ ntl init
|
40
|
+
|
41
|
+
Specify how far you want to go back in history
|
42
|
+
|
43
|
+
# all commit actions hereafter will be executed with the timestamp of current_time - 100 days
|
44
|
+
$ ntl config --set 100
|
45
|
+
|
46
|
+
Or
|
47
|
+
|
48
|
+
# all commit actions hereafter will be executed as if today was 02/05/2015
|
49
|
+
$ ntl config --go 02-05-15
|
50
|
+
|
51
|
+
### Use
|
52
|
+
|
53
|
+
* Run git actions with `ntl`
|
54
|
+
|
55
|
+
eg.
|
56
|
+
|
57
|
+
$ ntl git commit -am "message"
|
58
|
+
$ ntl git checkout -b "branch"
|
59
|
+
$ ntl git merge "branch"
|
60
|
+
...
|
61
|
+
|
62
|
+
ntl will ask for sudo password twice, once before the commit and once after. This is because the gem makes use of `date` command under the hood to change the system time.
|
63
|
+
|
64
|
+
* Fast forward or roll back in time
|
65
|
+
|
66
|
+
# All commit actions hereafter will be current_time - (previously_specified_date - 7 days)
|
67
|
+
$ ntl config --forward 7
|
68
|
+
|
69
|
+
# Similarly
|
70
|
+
$ ntl config --backward 7
|
71
|
+
|
72
|
+
## Todo
|
73
|
+
* Add Linux support
|
74
|
+
* Add Windows support
|
75
|
+
* Add set and revert system time commands
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/marwei/not_too_late.
|
80
|
+
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
85
|
+
|
data/Rakefile
ADDED
data/bin/ntl
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require File.join(File.dirname(__FILE__), "../lib/not_too_late")
|
5
|
+
|
6
|
+
time_travel = nil
|
7
|
+
|
8
|
+
opt_parser = OptionParser.new do |opt|
|
9
|
+
opt.banner = "Usage: ntl command [options]"
|
10
|
+
opt.separator ""
|
11
|
+
opt.separator " init: initialize git repo and create configuration file"
|
12
|
+
opt.separator " config: configure time travel settings. [-sfbg]"
|
13
|
+
opt.separator " git command: run git command with current time travel settings"
|
14
|
+
opt.separator ""
|
15
|
+
opt.separator "Options:"
|
16
|
+
|
17
|
+
opt.on "-s", "--set number_of_days", Numeric, "set how many days earlier the git actions will be made" do |arg|
|
18
|
+
time_travel = arg
|
19
|
+
end
|
20
|
+
|
21
|
+
opt.on "-f", "--forward number_of_days", Numeric, "fast forward the current setting by specified number of days" do |arg|
|
22
|
+
time_travel = NotTooLate::Command.get_time_travel - arg
|
23
|
+
end
|
24
|
+
|
25
|
+
opt.on "-b", "--backward number_of_days", Numeric, "roll backward the current setting by specified number of days" do |arg|
|
26
|
+
time_travel = NotTooLate::Command.get_time_travel + arg
|
27
|
+
end
|
28
|
+
opt.on "-g", "--go date (mm-dd-yy)", "set or change current date setting to the specified date." do |arg|
|
29
|
+
time_travel = (Date.today - Date.strptime(arg, '%m-%d-%y')).to_i
|
30
|
+
if time_travel < 0
|
31
|
+
puts opt_parser
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
opt.on "-h", "--help", "help" do
|
36
|
+
puts opt_parser
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# FIXME: this is a workaround to avoid git commands' flags being parsed here
|
41
|
+
# e.g. ntl git commit -am "initial commit" will exit with error if the
|
42
|
+
# following code was put after the opt_parser.parse!
|
43
|
+
if ARGV[0] == "git"
|
44
|
+
time_travel = NotTooLate::Command.get_time_travel
|
45
|
+
git_command = ' '
|
46
|
+
ARGV.each do |arg|
|
47
|
+
if arg.split.size > 1
|
48
|
+
git_command += "'#{arg}' "
|
49
|
+
else
|
50
|
+
git_command += "#{arg} "
|
51
|
+
end
|
52
|
+
end
|
53
|
+
NotTooLate.run time_travel, git_command
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
|
57
|
+
opt_parser.parse!
|
58
|
+
|
59
|
+
case ARGV[0]
|
60
|
+
when "init"
|
61
|
+
NotTooLate::Command.init_config
|
62
|
+
when "config"
|
63
|
+
if time_travel.nil?
|
64
|
+
puts "Invalid option"
|
65
|
+
else
|
66
|
+
NotTooLate::Command.set_time_travel time_travel
|
67
|
+
end
|
68
|
+
else
|
69
|
+
puts opt_parser
|
70
|
+
end
|
data/lib/not_too_late.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
dir = File.join(File.dirname(__FILE__), 'not_too_late/*')
|
2
|
+
Dir[dir].each {|file| require file }
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
module NotTooLate
|
6
|
+
class << self
|
7
|
+
def run(time_travel, git_command)
|
8
|
+
set_sys_time_to(Date.today - time_travel)
|
9
|
+
puts "running #{git_command}"
|
10
|
+
system git_command
|
11
|
+
system "sudo ntpdate -u time.apple.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def set_sys_time_to(date)
|
17
|
+
command = 'sudo date $(date "+' +
|
18
|
+
date.strftime("%m") +
|
19
|
+
date.strftime("%d") +
|
20
|
+
'%H%M' +
|
21
|
+
date.strftime("%y") +
|
22
|
+
'.%S")'
|
23
|
+
p command
|
24
|
+
system command
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module NotTooLate
|
2
|
+
module Command
|
3
|
+
class << self
|
4
|
+
def init_config
|
5
|
+
puts "initiaize config file"
|
6
|
+
Config.write({'time_travel' => 0})
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_time_travel
|
10
|
+
config = Config.read
|
11
|
+
config['time_travel']
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_time_travel(new_time)
|
15
|
+
config = Config.read
|
16
|
+
|
17
|
+
if config['time_travel'] != 0 && new_time > config['time_travel']
|
18
|
+
puts "You are traveling back in time again, "\
|
19
|
+
"this might cause unexpected results to your git history. "\
|
20
|
+
"Are you sure? (Press 'Y' to proceed, or any other key to abort"
|
21
|
+
return unless STDIN.gets.chomp! == 'Y'
|
22
|
+
end
|
23
|
+
config['time_travel'] = new_time
|
24
|
+
Config.write config
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module NotTooLate
|
4
|
+
module Config
|
5
|
+
class << self
|
6
|
+
def read
|
7
|
+
YAML.load_file file || {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def write(configs)
|
11
|
+
File.open(file, 'w') do |f|
|
12
|
+
f.write configs.to_yaml
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def file
|
17
|
+
path = `pwd`.chomp!
|
18
|
+
until Dir.exist? File.join(path, '.git')
|
19
|
+
path = File.expand_path('../', path)
|
20
|
+
end
|
21
|
+
File.join(path, '.ntl.yml')
|
22
|
+
end
|
23
|
+
|
24
|
+
def file_name
|
25
|
+
'.ntl.yml'
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def git_dir
|
30
|
+
"#{`pwd`.chomp!}/.git"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'not_too_late/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "not_too_late"
|
8
|
+
spec.version = NotTooLate::VERSION
|
9
|
+
spec.authors = ["Wei Zhu"]
|
10
|
+
spec.email = ["yo@weiz.hu"]
|
11
|
+
|
12
|
+
spec.homepage = "https://github.com/marwei/not_too_late"
|
13
|
+
spec.summary = "CLI for making git actions in the past"
|
14
|
+
spec.description = "CLI for making git actions in the past"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: not_too_late
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wei Zhu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: CLI for making git actions in the past
|
56
|
+
email:
|
57
|
+
- yo@weiz.hu
|
58
|
+
executables:
|
59
|
+
- ntl
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/ntl
|
71
|
+
- lib/not_too_late.rb
|
72
|
+
- lib/not_too_late/cli.rb
|
73
|
+
- lib/not_too_late/command.rb
|
74
|
+
- lib/not_too_late/config.rb
|
75
|
+
- lib/not_too_late/version.rb
|
76
|
+
- not_too_late.gemspec
|
77
|
+
homepage: https://github.com/marwei/not_too_late
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.4.8
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: CLI for making git actions in the past
|
101
|
+
test_files: []
|
102
|
+
has_rdoc:
|