-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.py
More file actions
executable file
·68 lines (55 loc) · 1.46 KB
/
git.py
File metadata and controls
executable file
·68 lines (55 loc) · 1.46 KB
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
#!/bin/env python3
from os.path import isfile, expandvars
from json import load
def configure():
write_gitconfig()
write_ignore()
write_message()
def write_message():
message_path = expandvars('$HOME/.gitmessage')
if not isfile(message_path):
with open(message_path, 'x') as message_file:
message_file.write("""Subject line (< 50 characters) imperative wording
Body for detailed description. Keep lines shorter than 72 characters
and give answer to the questions: what changed and why?
[Ticket|Issue|Reference: XXX]""")
def write_ignore():
ignore_path = expandvars('$HOME/.gitignore_global')
if not isfile(ignore_path):
with open(ignore_path, 'x') as ignore_file:
ignore_file.write("""# JetBrains Editors
.idea/
# GPG
secring.*
# VSCode
.vscode/
.history/
*.vsix""")
def write_gitconfig():
config_path = expandvars('$HOME/.gitconfig')
with open('git.json', 'r') as git_config:
config = load(git_config)
if not isfile(config_path):
with open(config_path, 'x') as config_file:
config_file.write(f"""[core]
editor = nvim
excludefile = ~/.gitignore_global
autocrlf = input
[commit]
template = ~/.gitmessage
[user]
email = {config["email"]}
name = {config["name"]}
signingkey = {config["signingkey"]}
[color]
ui = true
[alias]
dfs = diff --staged
logg = log --graph --decorate --oneline --all
praise = blame
amend = commit --amend
unstage = restore --staged
[init]
defaultBranch = main""")
if __name__ == '__main__':
configure()