Skip to content

Commit

Permalink
Enhancement: cleanup commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Sep 20, 2018
1 parent 3372083 commit eebbaf7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions GitSavvy.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,20 @@
*/
"rebase_preserve_merges": false,



/*
When set to `true`, GitSavvy will prompt for confirmation before actually
performing a `git push --force` operation.
*/
"confirm_force_push": true,

/*
This setting controls how commit messages are cleaned up in the commit view:
`git commit --cleanup=<mode>`. It is ignored if `git config commit.cleanup` is set.
*/
"commit_cleanup_default_mode": "strip",

/*
When set to `true`, closing the commit message window via keyboard will result
in a commit action being taken, except in cases where the message is empty.
Expand Down
7 changes: 6 additions & 1 deletion core/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def run(self, edit):

if has_prepare_commit_msg_hook and os.path.exists(commit_editmsg_path):
with util.file.safe_open(commit_editmsg_path, "r") as f:
initial_text = "\n" + f.read().rstrip() + help_text
initial_text = f.read().rstrip() + help_text
elif option_amend:
last_commit_message = self.git("log", "-1", "--pretty=%B").strip()
initial_text = last_commit_message + help_text
Expand Down Expand Up @@ -317,6 +317,10 @@ def run_async(self, commit_message=None):
help_text = view_settings.get("git_savvy.commit_view.help_text")
commit_message = view_text.split(help_text)[0]

cleanup_mode = self.git("config", "commit.cleanup", throw_on_stderr=False).strip()
if not cleanup_mode:
cleanup_mode = self.savvy_settings.get("commit_cleanup_default_mode", "strip")

include_unstaged = view_settings.get("git_savvy.commit_view.include_unstaged")

show_panel_overrides = self.savvy_settings.get("show_panel_for")
Expand All @@ -332,6 +336,7 @@ def run_async(self, commit_message=None):
"--amend" if view_settings.get("git_savvy.commit_view.amend") else None,
"-F",
"-",
"--cleanup={}".format(cleanup_mode),
stdin=commit_message
)
finally:
Expand Down

0 comments on commit eebbaf7

Please sign in to comment.