mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
BlenderBIM operator to add remote repo (#3096)
Procedure to merge a pull request would be: Add Remote, select the added remote in the pull-down, Fetch from remote, select the added remote branch in the pull-down, Merge, delete remote
This commit is contained in:
@@ -21,6 +21,7 @@ from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.AddFileToRepo,
|
||||
operator.AddRemote,
|
||||
operator.AddTag,
|
||||
operator.CloneRepo,
|
||||
operator.CommitChanges,
|
||||
|
||||
@@ -82,6 +82,7 @@ class CloneRepo(bpy.types.Operator):
|
||||
|
||||
props = context.scene.IfcGitProperties
|
||||
core.clone_repo(tool.IfcGit, props.remote_url, props.local_folder, self)
|
||||
props.remote_url = ""
|
||||
refresh()
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -303,6 +304,36 @@ class Fetch(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddRemote(bpy.types.Operator):
|
||||
"""Add a remote repository"""
|
||||
|
||||
bl_label = "Add Remote"
|
||||
bl_idname = "ifcgit.add_remote"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
IfcGitData.make_sure_is_loaded()
|
||||
props = context.scene.IfcGitProperties
|
||||
repo = IfcGitData.data["repo"]
|
||||
if (
|
||||
not repo
|
||||
or not tool.IfcGit.is_valid_ref_format(props.remote_name)
|
||||
or props.remote_name in [remote.name for remote in repo.remotes]
|
||||
or not props.remote_url
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
repo = IfcGitData.data["repo"]
|
||||
core.add_remote(tool.IfcGit, repo)
|
||||
bpy.ops.ifcgit.refresh()
|
||||
refresh()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DeleteRemote(bpy.types.Operator):
|
||||
"""Delete the selected remote"""
|
||||
|
||||
@@ -312,7 +343,6 @@ class DeleteRemote(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
props = context.scene.IfcGitProperties
|
||||
repo = IfcGitData.data["repo"]
|
||||
core.delete_remote(tool.IfcGit, repo)
|
||||
bpy.ops.ifcgit.refresh()
|
||||
|
||||
@@ -113,6 +113,11 @@ class IfcGitProperties(PropertyGroup):
|
||||
description="An optional human readable description of this tag",
|
||||
default="",
|
||||
)
|
||||
remote_name: StringProperty(
|
||||
name="New remote name",
|
||||
description="A local name for a remote Git repository",
|
||||
default="",
|
||||
)
|
||||
remote_url: StringProperty(
|
||||
name="Git URL",
|
||||
description="A URL pointing to a Git repository",
|
||||
|
||||
@@ -171,6 +171,14 @@ class IFCGIT_PT_panel(bpy.types.Panel):
|
||||
row.operator("ifcgit.push", icon="EXPERIMENTAL")
|
||||
row.operator("ifcgit.fetch", icon="IMPORT")
|
||||
|
||||
box = layout.box()
|
||||
row = box.row()
|
||||
row.prop(props, "remote_name")
|
||||
row = box.row()
|
||||
row.prop(props, "remote_url")
|
||||
row = box.row()
|
||||
row.operator("ifcgit.add_remote", icon="IMPORT")
|
||||
|
||||
|
||||
class COMMIT_UL_List(bpy.types.UIList):
|
||||
"""List of Git commits"""
|
||||
|
||||
@@ -42,6 +42,10 @@ def delete_tag(ifcgit, repo, tag_name):
|
||||
ifcgit.delete_tag(repo, tag_name)
|
||||
|
||||
|
||||
def add_remote(ifcgit, repo):
|
||||
ifcgit.add_remote(repo)
|
||||
|
||||
|
||||
def delete_remote(ifcgit, repo):
|
||||
ifcgit.delete_remote(repo)
|
||||
|
||||
|
||||
@@ -102,6 +102,13 @@ class IfcGit:
|
||||
if tag_name in repo.tags:
|
||||
repo.delete_tag(tag_name)
|
||||
|
||||
@classmethod
|
||||
def add_remote(cls, repo):
|
||||
props = bpy.context.scene.IfcGitProperties
|
||||
repo.create_remote(name=props.remote_name, url=props.remote_url)
|
||||
props.remote_name = ""
|
||||
props.remote_url = ""
|
||||
|
||||
@classmethod
|
||||
def delete_remote(cls, repo):
|
||||
props = bpy.context.scene.IfcGitProperties
|
||||
|
||||
Reference in New Issue
Block a user