1
+ import subprocess
1
2
import os
2
3
mypath = os .getcwd ()
3
4
infofile = mypath + '/.git/config'
4
5
6
+
5
7
def takeInfo ():
6
8
print ('No Existing repo info found\n ' )
7
9
url = str (input ('Enter the Github Repo URL: ' ))
8
10
branch = str (input ('Enter the branch: ' ))
9
- info = ['n' , url , branch ]
11
+ info = ['n' , url , branch ]
10
12
return info
11
13
14
+
12
15
def checkinfoInDir ():
13
16
if (os .path .exists (infofile )):
14
- print ('Repo Info Found:-' )
15
- with open (infofile , "r" ) as f :
16
- info = f .readlines ()
17
- # print(info)
18
- for ele in info :
19
- if ('url' in ele ):
20
- url = info [info .index (ele )].split ()[2 ]
17
+ url = subprocess .Popen ('git config --get remote.origin.url' ,
18
+ stdout = subprocess .PIPE ).stdout .read ().decode ('utf-8' )
21
19
22
- if ('branch' in ele ):
23
- branch = info [info .index (ele )].split ()[1 ].split ('"' )[1 ]
24
- info = [url , branch ]
20
+ branch = subprocess .Popen ('git rev-parse --symbolic-full-name HEAD' ,
21
+ stdout = subprocess .PIPE ).stdout .read ().decode ('utf-8' )
22
+
23
+ url , branch = url .split ('\n ' )[0 ], branch .split ('\n ' )[0 ].split ('/' )[2 ]
24
+ info = [url , branch ]
25
25
else :
26
26
info = takeInfo ()
27
27
return info
28
-
29
- print (checkinfoInDir ())
0 commit comments