File tree Expand file tree Collapse file tree 2 files changed +35
-13
lines changed
Expand file tree Collapse file tree 2 files changed +35
-13
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import argparse
3+
4+ from git import Repo
5+
6+ repo = Repo ("." )
7+
8+ def gaddc (message ):
9+ git = repo .git
10+ git .add ("." )
11+ git .commit ("-m" , message )
12+
13+ def parser_gp ():
14+ parser = argparse .ArgumentParser (description = "combination and simplification of some useful git commands" )
15+ subparser = parser .add_subparsers (help = "commands" )
16+
17+ addc = subparser .add_parser ("addc" , help = "add and commit" )
18+ addc .add_argument ("-m" , "--message" , help = "commit message" , required = True )
19+
20+ args = parser .parse_args ()
21+ print (args )
22+ if "message" in args :
23+ gaddc (args .message )
24+
25+ if __name__ == "__main__" :
26+ parser_gp ()
Original file line number Diff line number Diff line change 33
44from git import Repo
55
6- class GitPython :
7- def __init__ (self ):
8- self .repo = Repo ("." )
6+ repo = Repo ("." )
97
10- def add_and_commit (self , message ):
11- repo = self .repo
12- git = repo .git
13- git .add ("*" )
14- git .commit ("-m" , message )
15-
16- gitpython = GitPython ()
8+ def gaddc (message ):
9+ git = repo .git
10+ git .add ("." )
11+ git .commit ("-m" , message )
1712
1813def parser_gp ():
1914 parser = argparse .ArgumentParser (description = "combination and simplification of some useful git commands" )
2015 subparser = parser .add_subparsers (help = "commands" )
2116
2217 addc = subparser .add_parser ("addc" , help = "add and commit" )
23- addc .add_argument ("-m" , help = "commit message" , required = True )
18+ addc .add_argument ("-m" , "--message" , help = "commit message" , required = True )
2419
2520 args = parser .parse_args ()
26- if "m" in args :
27- gitpython .add_and_commit (args .m )
21+ print (args )
22+ if "message" in args :
23+ gaddc (args .message )
2824
2925if __name__ == "__main__" :
3026 parser_gp ()
You can’t perform that action at this time.
0 commit comments