@@ -27,7 +27,7 @@ def __init__(self, root_dir, name, path, url, fxtag=None, fxurl=None, fxsparse=N
27
27
"""
28
28
self .name = name
29
29
self .root_dir = root_dir
30
- self .path = path
30
+ self .path = path
31
31
self .url = url
32
32
self .fxurl = fxurl
33
33
self .fxtag = fxtag
@@ -37,14 +37,14 @@ def __init__(self, root_dir, name, path, url, fxtag=None, fxurl=None, fxsparse=N
37
37
else :
38
38
self .fxrequired = "AlwaysRequired"
39
39
self .logger = logger
40
-
40
+
41
41
def status (self ):
42
42
"""
43
43
Checks the status of the submodule and returns 4 parameters:
44
44
- result (str): The status of the submodule.
45
45
- needsupdate (bool): An indicator if the submodule needs to be updated.
46
46
- localmods (bool): An indicator if the submodule has local modifications.
47
- - testfails (bool): An indicator if the submodule has failed a test, this is used for testing purposes.
47
+ - testfails (bool): An indicator if the submodule has failed a test, this is used for testing purposes.
48
48
"""
49
49
50
50
smpath = os .path .join (self .root_dir , self .path )
@@ -54,7 +54,7 @@ def status(self):
54
54
ahash = None
55
55
optional = ""
56
56
if "Optional" in self .fxrequired :
57
- optional = " (optional)"
57
+ optional = " (optional)"
58
58
required = None
59
59
level = None
60
60
if not os .path .exists (os .path .join (smpath , ".git" )):
@@ -63,7 +63,7 @@ def status(self):
63
63
status , tags = rootgit .git_operation ("ls-remote" , "--tags" , self .url )
64
64
status , result = rootgit .git_operation ("submodule" ,"status" ,smpath )
65
65
result = result .split ()
66
-
66
+
67
67
if result :
68
68
ahash = result [0 ][1 :]
69
69
hhash = None
@@ -102,7 +102,7 @@ def status(self):
102
102
result = f"e { self .name :>20} has no associated remote"
103
103
testfails = True
104
104
needsupdate = True
105
- return result , needsupdate , localmods , testfails
105
+ return result , needsupdate , localmods , testfails
106
106
status , rurl = git .git_operation ("ls-remote" ,"--get-url" )
107
107
status , lines = git .git_operation ("log" , "--pretty=format:\" %h %d\" " )
108
108
line = lines .partition ('\n ' )[0 ]
@@ -148,15 +148,15 @@ def status(self):
148
148
else :
149
149
result = f"e { self .name :>20} has no fxtag defined in .gitmodules, module at { ahash } "
150
150
testfails = False
151
-
151
+
152
152
status , output = git .git_operation ("status" , "--ignore-submodules" , "-uno" )
153
153
if "nothing to commit" not in output :
154
154
localmods = True
155
155
result = "M" + textwrap .indent (output , " " )
156
156
# print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}")
157
157
return result , needsupdate , localmods , testfails
158
158
159
-
159
+
160
160
def _add_remote (self , git ):
161
161
"""
162
162
Adds a new remote to the submodule if it does not already exist.
@@ -170,7 +170,7 @@ def _add_remote(self, git):
170
170
171
171
Returns:
172
172
str: The name of the new remote if added, or the name of the existing remote that matches the submodule's URL.
173
- """
173
+ """
174
174
status , remotes = git .git_operation ("remote" , "-v" )
175
175
remotes = remotes .splitlines ()
176
176
upstream = None
@@ -212,7 +212,7 @@ def sparse_checkout(self):
212
212
213
213
Returns:
214
214
None
215
- """
215
+ """
216
216
self .logger .info ("Called sparse_checkout for {}" .format (self .name ))
217
217
rgit = GitInterface (self .root_dir , self .logger )
218
218
status , superroot = rgit .git_operation ("rev-parse" , "--show-superproject-working-tree" )
@@ -250,7 +250,7 @@ def sparse_checkout(self):
250
250
sprepo_git .config_set_value ("core" , "sparseCheckout" , "true" )
251
251
252
252
# set the repository remote
253
-
253
+
254
254
self .logger .info ("Setting remote origin in {}/{}" .format (self .root_dir , self .path ))
255
255
status , remotes = sprepo_git .git_operation ("remote" , "-v" )
256
256
if self .url not in remotes :
@@ -287,7 +287,7 @@ def sparse_checkout(self):
287
287
"submodule {} is already initialized {}" .format (self .name , rootdotgit )
288
288
)
289
289
os .remove (gitsparse )
290
-
290
+
291
291
if os .path .isfile (self .fxsparse ):
292
292
shutil .copy (self .fxsparse , gitsparse )
293
293
else :
@@ -376,21 +376,21 @@ async def update(self):
376
376
shutil .rmtree (os .path .join (repodir , ".git" ))
377
377
else :
378
378
shutil .move (os .path .join (repodir , ".git" ), newpath )
379
-
379
+
380
380
with open (os .path .join (repodir , ".git" ), "w" ) as f :
381
381
f .write ("gitdir: " + os .path .relpath (newpath , start = repodir ))
382
382
383
383
if not os .path .exists (repodir ):
384
384
parent = os .path .dirname (repodir )
385
385
if not os .path .isdir (parent ):
386
386
os .makedirs (parent )
387
- git .git_operation ("submodule" , "add" , "--name" , self .name , "--" , self .url , self .path )
387
+ git .git_operation ("submodule" , "add" , "--name" , self .name , "--" , self .url , self .path )
388
388
389
389
if not repo_exists :
390
390
git .git_operation ("submodule" , "init" , "--" , self .path )
391
391
await git .git_operation_async ("submodule" , "update" , "--" , self .path )
392
392
393
- if self .fxtag :
393
+ if self .fxtag :
394
394
smgit = GitInterface (repodir , self .logger )
395
395
newremote = self ._add_remote (smgit )
396
396
# Trying to distingush a tag from a hash
@@ -399,19 +399,23 @@ async def update(self):
399
399
if not set (self .fxtag ) <= allowed :
400
400
# This is a tag
401
401
tag = f"refs/tags/{ self .fxtag } :refs/tags/{ self .fxtag } "
402
- status ,_ = smgit .git_operation ("fetch" , newremote , tag )
402
+ #status,_ = smgit.git_operation("fetch", newremote, tag)
403
+ status , jn = smgit .git_operation ("fetch" , newremote , tag )
404
+ print ("Successfully fetch tag? -JN" , status , jn , self .fxtag ) #DEBUG -JN
403
405
if status == 0 :
404
- status ,_ = smgit .git_operation ("checkout" , self .fxtag )
406
+ #status,_ = smgit.git_operation("checkout", self.fxtag)
407
+ status ,jn = smgit .git_operation ("checkout" , self .fxtag )
408
+ print ("Successfully checkout tag? -JN" , status , jn , self .fxtag ) #DEBUG -JN
405
409
if status :
406
410
utils .fatal_error (
407
411
f"Failed to checkout { self .name } at tag or hash { self .fxtag } from { repodir } "
408
412
)
409
-
413
+
410
414
if not os .path .exists (os .path .join (repodir , ".git" )):
411
415
utils .fatal_error (
412
416
f"Failed to checkout { self .name } { repo_exists } { repodir } { self .path } "
413
417
)
414
-
418
+
415
419
416
420
if os .path .exists (os .path .join (self .path , ".git" )):
417
421
submoddir = os .path .join (self .root_dir , self .path )
@@ -443,7 +447,7 @@ async def update(self):
443
447
print (f"{ self .name :>20} updated to { fxtag } " )
444
448
except Exception as error :
445
449
print (error )
446
-
450
+
447
451
448
452
elif not fxtag :
449
453
print (f"No fxtag found for submodule { self .name :>20} " )
@@ -455,5 +459,5 @@ async def update(self):
455
459
print (f"{ self .name :>20} up to date." )
456
460
457
461
458
-
462
+
459
463
return
0 commit comments