diff --git a/blendgit.py b/__init__.py similarity index 92% rename from blendgit.py rename to __init__.py index 5018df1..fda8946 100644 --- a/blendgit.py +++ b/__init__.py @@ -28,19 +28,11 @@ # along with this program. If not, see . #- -import os -import time -import subprocess -import errno -import shutil -import bpy - -bl_info = \ - { +bl_info = { "name" : "Blendgit", "author" : "Lawrence D’Oliveiro ", "version" : (0, 5, 0), - "blender" : (2, 7, 4), + "blender" : (2, 80, 0), "location" : "File > Version Control", "description" : "manage versions of a .blend file using Git", "warning" : "", @@ -49,6 +41,13 @@ "category" : "System", } +import os +import time +import subprocess +import errno +import shutil +import bpy + def format_compact_datetime(timestamp) : # returns as brief as possible a human-readable display of the specified date/time. then_items = time.localtime(timestamp) @@ -149,8 +148,7 @@ class LoadVersion(bpy.types.Operator) : bl_idname = "file.version_control_load" bl_label = "Load Version..." - commit = bpy.props.EnumProperty \ - ( + commit : bpy.props.EnumProperty ( items = list_commits, name = "Commit", description = "which previously-saved commit to restore", @@ -190,10 +188,15 @@ class SaveVersion(bpy.types.Operator) : bl_idname = "file.version_control_save" bl_label = "Save Version..." - comment = bpy.props.StringProperty(name = "Comment") + comment : bpy.props.StringProperty( + name = "Comment", + description = "Git Commit Comment (max char 72)", + maxlen = 72, + default = "", + ) def draw(self, context) : - self.layout.prop(self, "comment", "") + self.layout.prop(self, "comment") #end draw def invoke(self, context, event): @@ -252,7 +255,8 @@ def execute(self, context) : #end if dst_path = os.path.join(work_dir, filepath) # keep relative path within work dir - os.link(os.path.join(parent_dir, filepath), dst_path) + if not os.path.exists(dst_path): # Avoid collisions from multiple scene copies + os.link(os.path.join(parent_dir, filepath), dst_path) # must be a hard link, else git commits the symlink do_git(("add", "--", dst_path), saving = True) # Git will quietly ignore this if file hasn’t changed @@ -287,15 +291,23 @@ def add_invoke_item(self, context) : self.layout.menu(VersionControlMenu.bl_idname) #end add_invoke_item +classes = [ + VersionControlMenu, + SaveVersion, + LoadVersion +] + def register() : - bpy.utils.register_module(__name__) - bpy.types.INFO_MT_file.append(add_invoke_item) + for c in classes: + bpy.utils.register_class(c) + bpy.types.TOPBAR_MT_file.append(add_invoke_item) #end register def unregister() : - bpy.types.INFO_MT_file.remove(add_invoke_item) - bpy.utils.unregister_module(__name__) -#end unregister + bpy.types.TOPBAR_MT_file.remove(add_invoke_item) + for c in classes: + bpy.utils.unregister_class(c) +# end unregister if __name__ == "__main__" : register()