Skip to content

Commit f367b49

Browse files
committed
Add debugging output to git-fleximod.
1 parent 5a32d0d commit f367b49

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

.lib/git-fleximod/git_fleximod/submodule.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, root_dir, name, path, url, fxtag=None, fxurl=None, fxsparse=N
2727
"""
2828
self.name = name
2929
self.root_dir = root_dir
30-
self.path = path
30+
self.path = path
3131
self.url = url
3232
self.fxurl = fxurl
3333
self.fxtag = fxtag
@@ -37,14 +37,14 @@ def __init__(self, root_dir, name, path, url, fxtag=None, fxurl=None, fxsparse=N
3737
else:
3838
self.fxrequired = "AlwaysRequired"
3939
self.logger = logger
40-
40+
4141
def status(self):
4242
"""
4343
Checks the status of the submodule and returns 4 parameters:
4444
- result (str): The status of the submodule.
4545
- needsupdate (bool): An indicator if the submodule needs to be updated.
4646
- 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.
4848
"""
4949

5050
smpath = os.path.join(self.root_dir, self.path)
@@ -54,7 +54,7 @@ def status(self):
5454
ahash = None
5555
optional = ""
5656
if "Optional" in self.fxrequired:
57-
optional = " (optional)"
57+
optional = " (optional)"
5858
required = None
5959
level = None
6060
if not os.path.exists(os.path.join(smpath, ".git")):
@@ -63,7 +63,7 @@ def status(self):
6363
status, tags = rootgit.git_operation("ls-remote", "--tags", self.url)
6464
status, result = rootgit.git_operation("submodule","status",smpath)
6565
result = result.split()
66-
66+
6767
if result:
6868
ahash = result[0][1:]
6969
hhash = None
@@ -102,7 +102,7 @@ def status(self):
102102
result = f"e {self.name:>20} has no associated remote"
103103
testfails = True
104104
needsupdate = True
105-
return result, needsupdate, localmods, testfails
105+
return result, needsupdate, localmods, testfails
106106
status, rurl = git.git_operation("ls-remote","--get-url")
107107
status, lines = git.git_operation("log", "--pretty=format:\"%h %d\"")
108108
line = lines.partition('\n')[0]
@@ -148,15 +148,15 @@ def status(self):
148148
else:
149149
result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {ahash}"
150150
testfails = False
151-
151+
152152
status, output = git.git_operation("status", "--ignore-submodules", "-uno")
153153
if "nothing to commit" not in output:
154154
localmods = True
155155
result = "M" + textwrap.indent(output, " ")
156156
# print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}")
157157
return result, needsupdate, localmods, testfails
158158

159-
159+
160160
def _add_remote(self, git):
161161
"""
162162
Adds a new remote to the submodule if it does not already exist.
@@ -170,7 +170,7 @@ def _add_remote(self, git):
170170
171171
Returns:
172172
str: The name of the new remote if added, or the name of the existing remote that matches the submodule's URL.
173-
"""
173+
"""
174174
status, remotes = git.git_operation("remote", "-v")
175175
remotes = remotes.splitlines()
176176
upstream = None
@@ -212,7 +212,7 @@ def sparse_checkout(self):
212212
213213
Returns:
214214
None
215-
"""
215+
"""
216216
self.logger.info("Called sparse_checkout for {}".format(self.name))
217217
rgit = GitInterface(self.root_dir, self.logger)
218218
status, superroot = rgit.git_operation("rev-parse", "--show-superproject-working-tree")
@@ -250,7 +250,7 @@ def sparse_checkout(self):
250250
sprepo_git.config_set_value("core", "sparseCheckout", "true")
251251

252252
# set the repository remote
253-
253+
254254
self.logger.info("Setting remote origin in {}/{}".format(self.root_dir, self.path))
255255
status, remotes = sprepo_git.git_operation("remote", "-v")
256256
if self.url not in remotes:
@@ -287,7 +287,7 @@ def sparse_checkout(self):
287287
"submodule {} is already initialized {}".format(self.name, rootdotgit)
288288
)
289289
os.remove(gitsparse)
290-
290+
291291
if os.path.isfile(self.fxsparse):
292292
shutil.copy(self.fxsparse, gitsparse)
293293
else:
@@ -376,21 +376,21 @@ async def update(self):
376376
shutil.rmtree(os.path.join(repodir, ".git"))
377377
else:
378378
shutil.move(os.path.join(repodir, ".git"), newpath)
379-
379+
380380
with open(os.path.join(repodir, ".git"), "w") as f:
381381
f.write("gitdir: " + os.path.relpath(newpath, start=repodir))
382382

383383
if not os.path.exists(repodir):
384384
parent = os.path.dirname(repodir)
385385
if not os.path.isdir(parent):
386386
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)
388388

389389
if not repo_exists:
390390
git.git_operation("submodule", "init", "--", self.path)
391391
await git.git_operation_async("submodule", "update", "--", self.path)
392392

393-
if self.fxtag:
393+
if self.fxtag:
394394
smgit = GitInterface(repodir, self.logger)
395395
newremote = self._add_remote(smgit)
396396
# Trying to distingush a tag from a hash
@@ -399,19 +399,23 @@ async def update(self):
399399
if not set(self.fxtag) <= allowed:
400400
# This is a tag
401401
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
403405
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
405409
if status:
406410
utils.fatal_error(
407411
f"Failed to checkout {self.name} at tag or hash {self.fxtag} from {repodir}"
408412
)
409-
413+
410414
if not os.path.exists(os.path.join(repodir, ".git")):
411415
utils.fatal_error(
412416
f"Failed to checkout {self.name} {repo_exists} {repodir} {self.path}"
413417
)
414-
418+
415419

416420
if os.path.exists(os.path.join(self.path, ".git")):
417421
submoddir = os.path.join(self.root_dir, self.path)
@@ -443,7 +447,7 @@ async def update(self):
443447
print(f"{self.name:>20} updated to {fxtag}")
444448
except Exception as error:
445449
print(error)
446-
450+
447451

448452
elif not fxtag:
449453
print(f"No fxtag found for submodule {self.name:>20}")
@@ -455,5 +459,5 @@ async def update(self):
455459
print(f"{self.name:>20} up to date.")
456460

457461

458-
462+
459463
return

0 commit comments

Comments
 (0)