Bug 443475 - Git Commit tool view doesn't display git commit errors
Summary: Git Commit tool view doesn't display git commit errors
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: VCS: Git (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Jonathan Verner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-08 12:48 UTC by Igor Kushnir
Modified: 2021-11-11 17:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.7.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Kushnir 2021-10-08 12:48:45 UTC
SUMMARY
Git Commit tool misbehaves when the `git commit` command it executes fails.

STEPS TO REPRODUCE
1. Clone a project with a commit hook that can fail. For example, KTextEditor.
2. Stage changes that the commit hook rejects. For example, misformat KTextEditor code.
3. Enter a commit message and click the Commit button in the Git Commit tool view.

OBSERVED RESULT
1. The commit message subject and body fields become disabled.
2. The git commit error message can be found in the Version Control tool view if the user enables and makes it visible. For example:
```
/path/to/ktexteditor> git commit -m e
Command exited with value 1.
ERROR: You have unformatted changes, please format your files. You can do this using the following commands:
       git clang-format --force # format the changed parts
       git clang-format --diff # preview the changes done by the formatter

Command finished with error UnknownError.
```

EXPECTED RESULT
1. The commit message subject and body fields remain enabled and editable.
2. The error with the actual `git commit` command output is shown to the user in one way or another. For example:
  a) the Version Control tool view becomes enabled and visible automatically;
  b) the error is shown in the Git Commit tool view somewhere;
  c) the error is shown at the top of the KDevelop window via `ICore::self()->uiController()->postMessage()`.
  d) the error is shown in a message box.

SOFTWARE/OS VERSIONS
Manjaro GNU/Linux, Xfce
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2+kde+r226
Comment 1 Jonathan Verner 2021-11-03 22:01:20 UTC
Its on my todo list :-)
Comment 2 Jonathan Verner 2021-11-11 17:23:32 UTC
Git commit 304907339df0f2185e29daacb411a0bed1af6395 by Jonathan L. Verner.
Committed on 11/11/2021 at 13:45.
Pushed by igorkushnir into branch 'release/21.12'.

Enable the commit form after git commit failure

This fixes a bug which would lead to the commit form being disabled and
unusable when a commit failed for some reason.

The commit form was disabled when the commit job started and was meant to
be enabled when the job finished. However, the wrong signal was connected
to, which meant that in case of failure the code never ran.
FIXED-IN: 5.7.0

M  +1    -1    plugins/git/committoolview.cpp

https://invent.kde.org/kdevelop/kdevelop/commit/304907339df0f2185e29daacb411a0bed1af6395
Comment 3 Jonathan Verner 2021-11-11 17:23:40 UTC
Git commit a99c312f4c7958f59d0ef41cb928f20f0dd44cfd by Jonathan L. Verner.
Committed on 11/11/2021 at 14:59.
Pushed by igorkushnir into branch 'release/21.12'.

Show an error message in the git commit view when committing fails

When committing fails, the user should be informed (and not expected to
notice this by seeing an error in the Version Control output view or knowing
commit message not being cleared means failure).

I opted to use a KMessageWidget instead of a Modal Dialog (per the HIG guidelines,
although they are a bit unclear, since there is no clear action that the
user can take to remedy the situation).

I also opted for just a short message pointing the user to the Version Control
output view for more information due to the limited space available in the
commit toolview.
FIXED-IN: 5.7.0

M  +3    -0    plugins/git/committoolview.cpp
M  +22   -0    plugins/git/simplecommitform.cpp
M  +19   -0    plugins/git/simplecommitform.h

https://invent.kde.org/kdevelop/kdevelop/commit/a99c312f4c7958f59d0ef41cb928f20f0dd44cfd