You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently found out about the power of .git/hooks/prepare-commit-msg but found out this plugin doesn't support it. So I modified this plugin to look for .git/hooks/SublimeTextGit-prepare-commit-msg use the contents of that file for the commit message. Unlike the other hooks, it's not a bash script which makes it easier to setup.
diff --git a/git/commit.py b/git/commit.py
index 90eb726..0cfcefd 100644
--- a/git/commit.py+++ b/git/commit.py@@ -8,6 +8,7 @@ import os
import sublime
import sublime_plugin
from . import GitTextCommand, GitWindowCommand, plugin_file, view_contents, _make_text_safeish
+from . import git_root
from .add import GitAddSelectedHunkCommand
history = []
@@ -106,6 +107,19 @@ class GitCommitCommand(GitWindowCommand):
if not len(self.lines):
self.lines = ["", ""]
+ if self.get_working_dir():+ git_root_dir = git_root(self.get_working_dir())+ else:+ git_root_dir = self.active_view().settings().get("git_root_dir")++ if git_root_dir:+ prepareCommitFilepath = os.path.join(git_root_dir, '.git', 'hooks', 'SublimeTextGit-prepare-commit-msg')+ if os.path.exists(prepareCommitFilepath):+ with open(prepareCommitFilepath, "r") as fin:+ self.lines = fin.read().split('\n')+ self.lines.extend([""])++
self.lines.extend(map(format, history[:historySize]))
self.lines.extend([
"# --------------",
My example .git/hooks/SublimeTextGit-prepare-commit-msg
I'm not sure if this is a feature you'd consider merging (and I've no idea what the proper filepath should be). I didn't see anyone ask for this feature however so it might be easier to not add it.
The text was updated successfully, but these errors were encountered:
I recently found out about the power of
.git/hooks/prepare-commit-msg
but found out this plugin doesn't support it. So I modified this plugin to look for.git/hooks/SublimeTextGit-prepare-commit-msg
use the contents of that file for the commit message. Unlike the other hooks, it's not a bash script which makes it easier to setup.My example
.git/hooks/SublimeTextGit-prepare-commit-msg
I'm not sure if this is a feature you'd consider merging (and I've no idea what the proper filepath should be). I didn't see anyone ask for this feature however so it might be easier to not add it.
The text was updated successfully, but these errors were encountered: