fix offline crash with updater
This commit is contained in:
parent
592f24aa9c
commit
7ba6dcb2d8
@ -48,7 +48,7 @@ class AboutUpgradeMightyScape(inkex.EffectExtension):
|
|||||||
if file.endswith('.inx'):
|
if file.endswith('.inx'):
|
||||||
totalInx += 1
|
totalInx += 1
|
||||||
|
|
||||||
inkex.utils.debug("There are {} extension folders with {} .inx files!".format(totalFolders, totalInx))
|
inkex.utils.debug("Locally there are {} extension folders with {} .inx files!".format(totalFolders, totalInx))
|
||||||
|
|
||||||
repo = Repo(os.path.join(main_dir, ".git"))
|
repo = Repo(os.path.join(main_dir, ".git"))
|
||||||
|
|
||||||
@ -62,47 +62,51 @@ class AboutUpgradeMightyScape(inkex.EffectExtension):
|
|||||||
inkex.utils.debug("There are some untracked files in your MightyScape directory. Still trying to pull recent files from git...")
|
inkex.utils.debug("There are some untracked files in your MightyScape directory. Still trying to pull recent files from git...")
|
||||||
|
|
||||||
origin = repo.remotes.origin
|
origin = repo.remotes.origin
|
||||||
|
try:
|
||||||
|
latestRemoteCommit = git.cmd.Git().ls_remote("https://gitea.fablabchemnitz.de/MarioVoigt/mightyscape-1.X.git", heads=True).replace('refs/heads/master','').strip()
|
||||||
|
localCommit = str(repo.head.commit)
|
||||||
|
#ref_logs = repo.head.reference.log()
|
||||||
|
|
||||||
latestRemoteCommit = git.cmd.Git().ls_remote("https://gitea.fablabchemnitz.de/MarioVoigt/mightyscape-1.X.git", heads=True).replace('refs/heads/master','').strip()
|
#commits = list(repo.iter_commits("master", max_count=5))
|
||||||
localCommit = str(repo.head.commit)
|
commits = list(repo.iter_commits("master"))
|
||||||
#ref_logs = repo.head.reference.log()
|
self.msg("Local commit id is: " + localCommit[:7])
|
||||||
|
self.msg("Latest remote commit is: " + latestRemoteCommit[:7])
|
||||||
|
self.msg("There are {} remote commits at the moment.".format(len(commits)))
|
||||||
|
#self.msg("There are {} remote ref logs at the moment.".format(len(ref_logs)))
|
||||||
|
commitList = []
|
||||||
|
for commit in commits:
|
||||||
|
commitList.append(commit)
|
||||||
|
#commitList.reverse()
|
||||||
|
#show last 10 entries
|
||||||
|
self.msg("*"*40)
|
||||||
|
self.msg("Latest 10 commits are:")
|
||||||
|
for i in range(0, 10):
|
||||||
|
self.msg("{} | {} : {}".format(
|
||||||
|
datetime.utcfromtimestamp(commitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
commitList[i].name_rev[:7],
|
||||||
|
commitList[i].message.strip())
|
||||||
|
)
|
||||||
|
#self.msg(" - {}: {}".format(commitList[i].newhexsha[:7], commitList[i].message))
|
||||||
|
self.msg("*"*40)
|
||||||
|
|
||||||
#commits = list(repo.iter_commits("master", max_count=5))
|
if localCommit != latestRemoteCommit:
|
||||||
commits = list(repo.iter_commits("master"))
|
ssh_executable = 'git'
|
||||||
self.msg("Local commit id is: " + localCommit[:7])
|
with repo.git.custom_environment(GIT_SSH=ssh_executable):
|
||||||
self.msg("Latest remote commit is: " + latestRemoteCommit[:7])
|
origin.fetch()
|
||||||
self.msg("There are {} remote commits at the moment.".format(len(commits)))
|
|
||||||
#self.msg("There are {} remote ref logs at the moment.".format(len(ref_logs)))
|
|
||||||
commitList = []
|
|
||||||
for commit in commits:
|
|
||||||
commitList.append(commit)
|
|
||||||
#commitList.reverse()
|
|
||||||
#show last 10 entries
|
|
||||||
self.msg("*"*40)
|
|
||||||
self.msg("Latest 10 commits are:")
|
|
||||||
for i in range(0, 10):
|
|
||||||
self.msg("{} | {} : {}".format(
|
|
||||||
datetime.utcfromtimestamp(commitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'),
|
|
||||||
commitList[i].name_rev[:7],
|
|
||||||
commitList[i].message.strip())
|
|
||||||
)
|
|
||||||
#self.msg(" - {}: {}".format(commitList[i].newhexsha[:7], commitList[i].message))
|
|
||||||
self.msg("*"*40)
|
|
||||||
|
|
||||||
if localCommit != latestRemoteCommit:
|
fetch_info = origin.pull() #finally pull new data
|
||||||
ssh_executable = 'git'
|
for info in fetch_info: #should return only one line in total
|
||||||
with repo.git.custom_environment(GIT_SSH=ssh_executable):
|
inkex.utils.debug("Updated %s to commit id %s" % (info.ref, str(info.commit)[:7]))
|
||||||
origin.fetch()
|
|
||||||
|
|
||||||
fetch_info = origin.pull() #finally pull new data
|
inkex.utils.debug("Please restart Inkscape to let the changes take effect.")
|
||||||
for info in fetch_info: #should return only one line in total
|
|
||||||
inkex.utils.debug("Updated %s to commit id %s" % (info.ref, str(info.commit)[:7]))
|
|
||||||
|
|
||||||
inkex.utils.debug("Please restart Inkscape to let the changes take effect.")
|
else:
|
||||||
|
inkex.utils.debug("Nothing to do! MightyScape is already up to date!")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
else:
|
except git.exc.GitCommandError:
|
||||||
inkex.utils.debug("Nothing to do! MightyScape is already up to date!")
|
self.msg("Error receiving latest remote commit from git. Are you offline? Cannot continue!")
|
||||||
exit(0)
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
inkex.utils.debug("No \".git\" directory found. Seems your MightyScape was not installed with git clone. Please see documentation on how to do that.")
|
inkex.utils.debug("No \".git\" directory found. Seems your MightyScape was not installed with git clone. Please see documentation on how to do that.")
|
||||||
|
Reference in New Issue
Block a user