#fetch_info = origin.pull() #finally pull new data
fetch_info=remote_repo.fetch()
remote_repo.pull()#finally pull new data
forinfoinfetch_info:#should return only one line in total
inkex.utils.debug("Updated {} to commit id {}. {} commits were pulled".format(info.ref,str(info.commit)[:7],remoteCommitCount-localCommitCount))
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!")
exceptgit.exc.GitCommandErrorase:
inkex.utils.debug("Error: ")
inkex.utils.debug(e)
returnFalse
returnTrue
defadd_arguments(self,pars):
pars.add_argument("--tab")
pars.add_argument("--convert_to_git",type=inkex.Boolean,default=False,help="If you downloaded MightyScape as .zip or .tar.gz you cannot upgrade using this extension. But you can convert your downloaded directory to a .git one by enabling this option")
pars.add_argument("--recreate_remotes",type=inkex.Boolean,default=False,help="Update remotes in git config file (useful if you have an older version of MightyScape or if sth. changes)")
pars.add_argument("--stash_untracked",type=inkex.Boolean,default=False,help="Stash untracked files and continue to upgrade")
defeffect(self):
globalso
so=self.options
warnings.simplefilter('ignore',ResourceWarning)#suppress "enable tracemalloc to get the object allocation traceback"
#get the directory of mightyscape
extension_dir=os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../'))#go up to main dir /home/<user>/.config/inkscape/extensions/mightyscape-1.2/
main_dir=os.path.abspath(os.path.join(extension_dir,'../../'))#go up to main dir /home/<user>/.config/inkscape/extensions/mightyscape-1.2/
#create some statistics
totalFolders=0
forroot,folders,filesinos.walk(extension_dir):
totalFolders+=len(folders)
break#prevent descending into subfolders
totalInx=0
forroot,folders,filesinos.walk(extension_dir):
forfileinfiles:
iffile.endswith('.inx'):
totalInx+=1
inkex.utils.debug("Locally there are {} extension folders with {} .inx files!\n".format(totalFolders,totalInx))
inkex.utils.debug("MightyScape .git directory was not found. It seems you installed MightyScape the traditional way (by downloading and extracting from archive). Please install MightyScape using the git clone method if you want to use the upgrade function. More details can be found in the official README.")
exit(1)
local_repo=Repo(gitDir)
#drop local changed. update might fail if file changes are present
ifso.stash_untrackedisTrue:
local_repo.git.stash('save')
existingRemotes=[]#check for existing remotes. if one is missing, add it (or delete and recreate)
forrinlocal_repo.remotes:
existingRemotes.append(str(r))
forremoteinremotes:
ifremote[1]notinexistingRemotes:
local_repo.create_remote(remote[1],url=remote[0])
ifso.recreate_remotesisTrue:#delete and then recreate