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

Clean up of status reporting of failed operations #8311

Merged
merged 4 commits into from Jul 15, 2020

Conversation

RussKie
Copy link
Member

@RussKie RussKie commented Jul 12, 2020

Proposed changes

Undo plumbing and infra introduced in 1572cbd. With that we have one less dependency on WPF stack.

There are several scenarios that involve showing FormStatus or its descendants.

  1. Show a progress as a modal dialog (this is standard way).
  2. Do not show the progress dialog, and only show it if an operation that was running failed (e.g. staging files in FormCommit).

The approach to showing results of failed operations appears to be unnecessary complex, that IIUC led to issues while attempting to show a dialog that was already considered opened but invisible.
And the WPF's DispatcherFrameModalController was used to deal with this.
This also necessitated defining delegates, and required more plumbing to pass those around, validation, etc.

However it is much simpler not to show the dialog until after the operation has failed. The callsites are also much easier to read and understand.

Also some general code clean up.

⚠️ NB: best to review commit by commit. Don't squash.

Test methodology

Lots of manual tests

  • for normal operations (e.g. running git fetch and git fetch -all)
  • for no-dialog operation (e.g. file staging) that were set to fail (e.g. convert EOL from crlf to lf in one of the existing files in a repo)

Undo plumbing and infra introduced in 1572cbd.
With that we have one less dependency on WPF stack.

There are several scenarios that involve showing `FormStatus` or its descendants.
1. Show a progress as a modal dialog (this is standard way).
2. Do not show the progress dialog, and only show it if an operation that
was running failed (e.g. staging files in `FormCommit`).

The approach to showing results of failed operations appears to be unnecessay
complex, that IIUC led to issues while attempting to show a dialog that was
already considered opened but invisible.
And the WPF's DispatcherFrameModalController was used to deal with this.
This also necessitated defining delegates, and required more plumbing to
pass those around, validation, etc.

However it is much simpler *not* to show the dialog *until after* the operation
has failed.
The callsites are also much easier to read and understand.
@ghost ghost assigned RussKie Jul 12, 2020
@codecov
Copy link

codecov bot commented Jul 12, 2020

Codecov Report

Merging #8311 into master will increase coverage by 0.02%.
The diff coverage is 31.57%.

@@            Coverage Diff             @@
##           master    #8311      +/-   ##
==========================================
+ Coverage   52.68%   52.70%   +0.02%     
==========================================
  Files         864      864              
  Lines       62509    62474      -35     
  Branches    11194    11187       -7     
==========================================
- Hits        32933    32928       -5     
+ Misses      26965    26929      -36     
- Partials     2611     2617       +6     
Flag Coverage Δ
#production 40.72% <31.57%> (+0.02%) ⬆️
#tests 94.44% <ø> (-0.04%) ⬇️

@RussKie
Copy link
Member Author

RussKie commented Jul 15, 2020

@msftbot merge in 2 days

@ghost ghost added the status: auto merge label Jul 15, 2020
@ghost
Copy link

ghost commented Jul 15, 2020

Hello @RussKie!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Fri, 17 Jul 2020 08:18:18 GMT, which is in 2 days

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. Have not tested. Just a few nits.

Comment on lines +99 to 100
using (var form = new FormStatus(commands: null, new EditboxBasedConsoleOutputControl(), useDialogSettings: true))
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using (var form = new FormStatus(commands: null, new EditboxBasedConsoleOutputControl(), useDialogSettings: true))
{
using var form = new FormStatus(commands: null, new EditboxBasedConsoleOutputControl(), useDialogSettings: true);


_errorOccurred = !isSuccess;

if (isSuccess && !_showOnError && (_useDialogSettings && AppSettings.CloseProcessDialog))
if (isSuccess && (_useDialogSettings && AppSettings.CloseProcessDialog))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isSuccess && (_useDialogSettings && AppSettings.CloseProcessDialog))
if (isSuccess && _useDialogSettings && AppSettings.CloseProcessDialog)

}

internal void Start()
private void Start()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private methods are not sorted.

public Action<FormStatus> AbortCallback;
private bool _errorOccurred;
private bool _showOnError;
private protected ConsoleOutputControl ConsoleOutput { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properties between methods?

@RussKie
Copy link
Member Author

RussKie commented Jul 15, 2020

Thank you. There's more clean up to do, I'll address the nits in the follow up PRs.

@RussKie RussKie merged commit 246121a into gitextensions:master Jul 15, 2020
@ghost ghost added this to the 4.0 milestone Jul 15, 2020
@RussKie RussKie deleted the Simplify_FormStatus_API branch July 15, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants