working on some update script

This commit is contained in:
Mario Voigt 2021-05-14 01:33:26 +02:00
parent 8b92f964ae
commit 3415119ab0
2 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Upgrade MightyScape</name> <name>Upgrade MightyScape</name>
<id>fablabchemnitz.de.upgrade_mightyscape</id> <id>fablabchemnitz.de.upgrade_mightyscape</id>
<param name="stash_untracked" type="bool" gui-text="Stash untracked files and continue to upgrade">false</param> <param name="stash_untracked" type="bool" gui-hidden="true" gui-text="Stash untracked files and continue to upgrade">false</param>
<effect needs-live-preview="false"> <effect needs-live-preview="false">
<object-type>all</object-type> <object-type>all</object-type>
<effects-menu> <effects-menu>

View File

@ -13,7 +13,8 @@ License: GNU GPL v3
import inkex import inkex
import os import os
from git import Repo import warnings
from git import Repo #requires GitPython lib
class Upgrade(inkex.EffectExtension): class Upgrade(inkex.EffectExtension):
@ -21,6 +22,8 @@ class Upgrade(inkex.EffectExtension):
pars.add_argument("--stash_untracked", type=inkex.Boolean, default=False, help="Stash untracked files and continue to upgrade") pars.add_argument("--stash_untracked", type=inkex.Boolean, default=False, help="Stash untracked files and continue to upgrade")
def effect(self): def effect(self):
warnings.simplefilter('ignore', ResourceWarning) #suppress "enable tracemalloc to get the object allocation traceback"
#get the directory of mightyscape #get the directory of mightyscape
extension_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../', '../') #go up to dir /home/<user>/.config/inkscape/extensions/mightyscape-1.X/ extension_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../', '../') #go up to dir /home/<user>/.config/inkscape/extensions/mightyscape-1.X/
@ -37,15 +40,18 @@ class Upgrade(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
fetch_info = origin.fetch()
for info in fetch_info:
inkex.utils.debug("Updated %s to %s" % (info.ref, info.commit))
#finally pull new data ssh_executable = 'git'
origin.pull() with repo.git.custom_environment(GIT_SSH=ssh_executable):
origin.fetch()
#hcommit = repo.head.commit
#hcommit.diff()
fetch_info = origin.pull() #finally pull new data
for info in fetch_info:
inkex.utils.debug("Updated %s to commit id %s" % (info.ref, str(info.commit)[:7]))
else: else:
inkex.utils.debug("MightyScape is up to date!") inkex.utils.debug("Nothing to do! MightyScape is already up to date!")
exit(0) exit(0)
else: else: