mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
BlenderBIM set gitattributes and autocrlf
Force Git to always treat IFC files as text. Store IFC in Git with LF line-endings, but checked-out files are CRLF on Windows.
This commit is contained in:
@@ -137,7 +137,7 @@ class CommitChanges(bpy.types.Operator):
|
||||
class AddTag(bpy.types.Operator):
|
||||
"""Tag selected revision"""
|
||||
|
||||
bl_label = "Add tag"
|
||||
bl_label = "Tag selected revision"
|
||||
bl_idname = "ifcgit.add_tag"
|
||||
bl_options = {"REGISTER"}
|
||||
|
||||
@@ -260,7 +260,7 @@ class Push(bpy.types.Operator):
|
||||
props = context.scene.IfcGitProperties
|
||||
repo = IfcGitData.data["repo"]
|
||||
remote = repo.remotes[props.select_remote]
|
||||
remote.push()
|
||||
remote.push(refspec=IfcGitData.data["repo"].active_branch.name)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -16,10 +16,24 @@ class IfcGit:
|
||||
@classmethod
|
||||
def init_repo(cls, path_dir):
|
||||
IfcGitRepo.repo = git.Repo.init(path_dir)
|
||||
autocrlf = "input"
|
||||
if os.name == "nt":
|
||||
autocrlf = "true"
|
||||
IfcGitRepo.repo.config_writer().set_value("core", "autocrlf", autocrlf)
|
||||
cls.config_info_attributes(IfcGitRepo.repo)
|
||||
|
||||
@classmethod
|
||||
def clone_repo(cls, remote_url, local_folder):
|
||||
IfcGitRepo.repo = git.Repo.clone_from(remote_url, local_folder)
|
||||
autocrlf = "input"
|
||||
if os.name == "nt":
|
||||
autocrlf = "true"
|
||||
IfcGitRepo.repo = git.Repo.clone_from(
|
||||
url=remote_url,
|
||||
to_path=local_folder,
|
||||
allow_unsafe_options=True,
|
||||
multi_options=["--config core.autocrlf=" + autocrlf],
|
||||
)
|
||||
cls.config_info_attributes(IfcGitRepo.repo)
|
||||
return IfcGitRepo.repo
|
||||
|
||||
@classmethod
|
||||
@@ -355,6 +369,15 @@ class IfcGit:
|
||||
config_writer.set_value(section, "cmd", "ifcmerge $BASE $LOCAL $REMOTE $MERGED")
|
||||
config_writer.set_value(section, "trustExitCode", True)
|
||||
|
||||
@classmethod
|
||||
def config_info_attributes(cls, repo):
|
||||
"""Set IFC files as text in .git/info/attributes"""
|
||||
path_attributes = os.path.join(repo.git_dir, "info", "attributes")
|
||||
if not os.path.exists(path_attributes):
|
||||
with open(path_attributes, "w") as f:
|
||||
f.write("*.ifc text\n")
|
||||
f.write("*.IFC text")
|
||||
|
||||
@classmethod
|
||||
def execute_merge(cls, path_ifc, operator):
|
||||
props = bpy.context.scene.IfcGitProperties
|
||||
|
||||
Reference in New Issue
Block a user