-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.rb
More file actions
35 lines (31 loc) · 962 Bytes
/
commit.rb
File metadata and controls
35 lines (31 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'thor'
require 'tzinfo'
require 'rb-readline'
require 'pry-byebug'
class Commit < Thor
desc 'new', 'Create commit with the file format'
method_option :yesterday,
aliases: '-y',
desc: 'Create commit with yesterday\'s date.',
default: 1,
type: :numeric,
lazy_default: true
def new
commit_format = if options[:yesterday].class == TrueClass || options[:yesterday].to_i
offset = if options[:yesterday].class == TrueClass
1
else
options[:yesterday].to_i
end
format_date(DateTime.now - offset)
else
format_date(DateTime.now)
end
system("git commit -m #{commit_format}")
end
no_commands do
def format_date(date)
commit_format = "#{date.strftime("%Y%m%d")}."
end
end
end