Skip to content

Commit

Permalink
Fix: Commit view respect the include_unstaged
Browse files Browse the repository at this point in the history
Fix #815
  • Loading branch information
stoivo committed Nov 26, 2017
1 parent 6fdaf3d commit c06e936
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions core/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def run(self, edit):
else COMMIT_HELP_TEXT)
self.view.settings().set("git_savvy.commit_view.help_text", help_text)

include_unstaged = self.view.settings().get("git_savvy.commit_view.include_unstaged", False)
option_amend = self.view.settings().get("git_savvy.commit_view.amend")
if option_amend:
last_commit_message = self.git("log", "-1", "--pretty=%B").strip()
Expand All @@ -110,22 +111,23 @@ def run(self, edit):
initial_text += f.read()

show_commit_diff = savvy_settings.get("show_commit_diff")
git_args = [
"diff",
"--no-color"
]

if show_commit_diff == "stat":
initial_text += self.git(
"diff",
"--stat",
"--no-color",
"--cached",
"HEAD^" if option_amend else None
)
elif show_commit_diff == "full" or show_commit_diff is True:
initial_text += self.git(
"diff",
"--no-color",
"--cached",
"HEAD^" if option_amend else None
)
git_args.append("--stat")

if not include_unstaged:
git_args.append("--cached")

if option_amend:
git_args.append("HEAD^")
elif include_unstaged:
git_args.append("HEAD")

initial_text += self.git(*git_args) if show_commit_diff != 'false' else ''
self.view.run_command("gs_replace_view_text", {
"text": initial_text,
"nuke_cursors": True
Expand Down

0 comments on commit c06e936

Please sign in to comment.