some adjustments in upgrader

This commit is contained in:
Mario Voigt 2021-06-23 08:28:12 +02:00
parent adf720fa11
commit 3258a1c915

View File

@ -7,8 +7,13 @@ Extension for InkScape 1.X
Author: Mario Voigt / FabLab Chemnitz Author: Mario Voigt / FabLab Chemnitz
Mail: mario.voigt@stadtfabrikanten.org Mail: mario.voigt@stadtfabrikanten.org
Date: 14.05.2021 Date: 14.05.2021
Last patch: 14.05.2021 Last patch: 23.06.2021
License: GNU GPL v3 License: GNU GPL v3
ToDo
- enable stash option
- add while loop to list all remoteCommits by jumping from parent to parent
- add option to create/init .git repo from zip downloaded MightyScape version (to enable upgrader) if no .git dir was found
""" """
import inkex import inkex
@ -26,33 +31,36 @@ class AboutUpgradeMightyScape(inkex.EffectExtension):
def update(self, local_repo, remote): def update(self, local_repo, remote):
try: try:
latestRemoteCommit = git.cmd.Git().ls_remote(remote, heads=True).replace('refs/heads/master','').strip() localCommit = local_repo.head.commit
localCommit = str(local_repo.head.commit) remote_repo = git.remote.Remote(local_repo, 'origin')
#ref_logs = local_repo.head.reference.log() remoteCommit = remote_repo.fetch()[0].commit
authors = []
# for every remote commit
while remoteCommit.hexsha != localCommit.hexsha:
authors.append(remoteCommit.author.email)
remoteCommit = remoteCommit.parents[0]
#commits = list(local_repo.iter_commits("master", max_count=5)) #local_commits = list(local_repo.iter_commits("master", max_count=5))
commits = list(local_repo.iter_commits("master")) local_commits = list(local_repo.iter_commits("master"))
self.msg("Local commit id is: " + localCommit[:7]) self.msg("Local commit id is: " + str(localCommit)[:7])
self.msg("Latest remote commit is: " + latestRemoteCommit[:7]) self.msg("Latest remote commit is: " + str(remoteCommit)[:7])
self.msg("There are {} remote commits at the moment.".format(len(commits))) self.msg("There are {} local commits at the moment.".format(len(local_commits)))
#self.msg("There are {} remote ref logs at the moment.".format(len(ref_logs))) localCommitList = []
commitList = [] for local_commit in local_commits:
for commit in commits: localCommitList.append(local_commit)
commitList.append(commit) #localCommitList.reverse()
#commitList.reverse()
#show last 10 entries
self.msg("*"*40) self.msg("*"*40)
self.msg("Latest 10 commits are:") self.msg("Latest 10 local commits are:")
for i in range(0, 10): for i in range(0, 10):
self.msg("{} | {} : {}".format( self.msg("{} | {} : {}".format(
datetime.utcfromtimestamp(commitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'), datetime.utcfromtimestamp(localCommitList[i].committed_date).strftime('%Y-%m-%d %H:%M:%S'),
commitList[i].name_rev[:7], localCommitList[i].name_rev[:7],
commitList[i].message.strip()) localCommitList[i].message.strip())
) )
#self.msg(" - {}: {}".format(commitList[i].newhexsha[:7], commitList[i].message)) #self.msg(" - {}: {}".format(localCommitList[i].newhexsha[:7], localCommitList[i].message))
self.msg("*"*40) self.msg("*"*40)
if localCommit != latestRemoteCommit: if localCommit.hexsha != remoteCommit.hexsha:
ssh_executable = 'git' ssh_executable = 'git'
with local_repo.git.custom_environment(GIT_SSH=ssh_executable): with local_repo.git.custom_environment(GIT_SSH=ssh_executable):
origin = local_repo.remotes.origin origin = local_repo.remotes.origin