File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import argparse
4+ import os
5+ from github_secrets import GITHUB_API_TOKEN
6+
7+
8+ def parseArgs ():
9+ parser = argparse .ArgumentParser (description = 'Push an existing local repository to a newly created remote repository of the same name' ) # noqa: E501
10+ parser .add_argument ('path' ,
11+ metavar = 'PATH' ,
12+ type = str ,
13+ help = 'Enter the path for existing local repository' )
14+ parser .add_argument ('url' ,
15+ metavar = 'URL' ,
16+ type = str ,
17+ help = 'Enter the newly created remote repository url (.git)' )
18+ parser .add_argument ('description' ,
19+ metavar = 'DESCRIPTION' ,
20+ type = str ,
21+ help = 'Enter the description for remote repository' )
22+ args = parser .parse_args ()
23+ return args
24+
25+
26+ def pushRepo (remote_url ):
27+ origin = remote_url [:8 ] + GITHUB_API_TOKEN + "@" + remote_url [8 :]
28+ os .system (f'git push { origin } --mirror' )
29+
30+
31+ def main ():
32+ path = args .path
33+ remote_url = args .url
34+
35+ os .chdir (path )
36+ if os .path .isdir ('./.git' ) is False :
37+ print ("Not in a git directory" )
38+ exit ()
39+
40+ pushRepo (remote_url )
41+
42+
43+ if __name__ == "__main__" :
44+ args = parseArgs ()
45+ main ()
You can’t perform that action at this time.
0 commit comments