-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctm.py
77 lines (49 loc) · 1.6 KB
/
ctm.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
"""
git Commit Time Machine
~~~~~~~~~~~~~~~~~~~~~~~
A command-line tool for easy commits with desired timestamp.
:copyright: (c) 2018 by Pavlo Dmytrenko.
:license: MIT, see LICENSE for more details.
"""
from __future__ import print_function
import os
from docopt import docopt
__version__ = '0.2.0'
CLI_SPEC = """\
Usage: ctm -d <date> -m <msg>
ctm -p
-d <date> Commit date and time
-m <msg> Commit message
-p Print date template
--help Print usage
--version Print version
"""
CMD_TMPL = ("GIT_AUTHOR_DATE='{date}' "
"GIT_COMMITTER_DATE='{date}' "
"git commit -m '{msg}'")
DATE_TMPL = 'Wed Feb 7 11:11:11 2018 +0200'
VERSION_TMPL = """\
██████╗████████╗███╗ ███╗
██╔════╝╚══██╔══╝████╗ ████║
██║ ██║ ██╔████╔██║
██║ ██║ ██║╚██╔╝██║
╚██████╗ ██║ ██║ ╚═╝ ██║
╚═════╝ ╚═╝ ╚═╝ ╚═╝
git Commit Time Machine
https://github.com/pavdmyt/git-ctm
VERSION %s
"""
def main():
args = docopt(CLI_SPEC, version=VERSION_TMPL % __version__)
date = args['-d']
msg = args['-m']
print_tmpl = args['-p']
if print_tmpl:
print(repr(DATE_TMPL))
return
cmd = CMD_TMPL.format(**{'date': date, 'msg': msg})
print(cmd)
os.system(cmd)
if __name__ == '__main__':
main()