Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.8 update #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 32 additions & 20 deletions blendgit.py → __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-

import os
import time
import subprocess
import errno
import shutil
import bpy

bl_info = \
{
bl_info = {
"name" : "Blendgit",
"author" : "Lawrence D’Oliveiro <[email protected]>",
"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" : "",
Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down