BlenderBIM push Git tags to remote

Shows error message if push fails
This commit is contained in:
Bruno Postle
2023-06-20 08:50:13 +01:00
parent e719055d9a
commit 7aafa87b52
4 changed files with 21 additions and 8 deletions
@@ -132,7 +132,7 @@ class CommitChanges(bpy.types.Operator):
def execute(self, context):
repo = IfcGitData.data["repo"]
core.commit_changes(tool.IfcGit, tool.Ifc, repo, context)
core.commit_changes(tool.IfcGit, tool.Ifc, repo)
bpy.ops.ifcgit.refresh()
refresh()
return {"FINISHED"}
@@ -215,7 +215,7 @@ class DisplayRevision(bpy.types.Operator):
def execute(self, context):
core.colourise_revision(tool.IfcGit, context)
core.colourise_revision(tool.IfcGit)
refresh()
return {"FINISHED"}
@@ -283,8 +283,7 @@ class Push(bpy.types.Operator):
props = context.scene.IfcGitProperties
repo = IfcGitData.data["repo"]
remote = repo.remotes[props.select_remote]
remote.push(refspec=IfcGitData.data["repo"].active_branch.name)
core.push(tool.IfcGit, repo, props.select_remote, self)
return {"FINISHED"}
@@ -168,7 +168,7 @@ class IFCGIT_PT_panel(bpy.types.Panel):
row.label(text=urls[props.select_remote])
row.operator("ifcgit.delete_remote", text="", icon="PANEL_CLOSE")
row = layout.row()
row.operator("ifcgit.push", icon="EXPERIMENTAL")
row.operator("ifcgit.push", icon="EXPORT")
row.operator("ifcgit.fetch", icon="IMPORT")
box = layout.box()
@@ -177,7 +177,7 @@ class IFCGIT_PT_panel(bpy.types.Panel):
row = box.row()
row.prop(props, "remote_url")
row = box.row()
row.operator("ifcgit.add_remote", icon="IMPORT")
row.operator("ifcgit.add_remote", icon="ADD")
class COMMIT_UL_List(bpy.types.UIList):
+8 -2
View File
@@ -26,7 +26,7 @@ def discard_uncomitted(ifcgit, ifc):
ifcgit.load_project(path_ifc)
def commit_changes(ifcgit, ifc, repo, context):
def commit_changes(ifcgit, ifc, repo):
path_ifc = ifc.get_path()
ifcgit.git_commit(path_ifc)
@@ -50,11 +50,17 @@ def delete_remote(ifcgit, repo):
ifcgit.delete_remote(repo)
def push(ifcgit, repo, remote_name, operator):
error_message = ifcgit.push(repo, remote_name, repo.active_branch.name)
if error_message:
operator.report({"ERROR"}, error_message)
def refresh_revision_list(ifcgit, repo, ifc):
ifcgit.refresh_revision_list(ifc.get_path())
def colourise_revision(ifcgit, context):
def colourise_revision(ifcgit):
step_ids = ifcgit.get_revisions_step_ids()
if not step_ids:
+8
View File
@@ -118,6 +118,14 @@ class IfcGit:
if repo.remotes:
props.select_remote = repo.remotes[0].name
@classmethod
def push(cls, repo, remote_name, branch_name):
remote = repo.remotes[remote_name]
try:
remote.push(tags=True, refspec=branch_name).raise_if_error()
except git.exc.GitCommandError as exc:
return exc.stderr
@classmethod
def create_new_branch(cls):
props = bpy.context.scene.IfcGitProperties