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

FormBrowse: Add all supported shells to the toolbar #8213

Merged
merged 2 commits into from Jul 10, 2020

Conversation

pmiossec
Copy link
Member

@pmiossec pmiossec commented Jun 11, 2020

Fixes #6460

Proposed changes

  • Being able to launch console of other shells (powershell, cmd, pwsh)

Screenshots

Before

image

After

image

Test methodology

  • Manual

Test environment(s)

  • Git Extensions 33.33.33
  • Build 9bf0b97
  • Git 2.25.0.windows.1 (recommended: 2.25.1 or later)
  • Microsoft Windows NT 6.2.9200.0
  • .NET Framework 4.8.4180.0
  • DPI 168dpi (175% scaling)

@codecov
Copy link

codecov bot commented Jun 11, 2020

Codecov Report

Merging #8213 into master will increase coverage by 0.02%.
The diff coverage is 44.89%.

@@            Coverage Diff             @@
##           master    #8213      +/-   ##
==========================================
+ Coverage   52.63%   52.65%   +0.02%     
==========================================
  Files         857      863       +6     
  Lines       62464    62503      +39     
  Branches    11185    11189       +4     
==========================================
+ Hits        32875    32910      +35     
+ Misses      26969    26966       -3     
- Partials     2620     2627       +7     
Flag Coverage Δ
#production 40.65% <44.89%> (+0.06%) ⬆️
#tests 94.45% <ø> (-0.01%) ⬇️

@RussKie
Copy link
Member

RussKie commented Jun 11, 2020

Nice!
Do you think we could get different icons for each?

GitUI/ShellHelper.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

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

ok

GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
@pmiossec
Copy link
Member Author

Still need to address messagebox comments but here are custom shell icons... (with updated screenshot)

@RussKie
Copy link
Member

RussKie commented Jun 12, 2020 via email

@pmiossec
Copy link
Member Author

Message boxes stuff done (with some not translated more strings...)

GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
GitUI/MessageBoxes.cs Outdated Show resolved Hide resolved
@pmiossec pmiossec force-pushed the launch_shell_consoles branch 2 times, most recently from e5b028a to 82be5ce Compare June 13, 2020 23:19
@RussKie
Copy link
Member

RussKie commented Jun 14, 2020

The existing code that deals with shells is starting to rot quickly, turning into a mess that we had with difftools resolution.
I took a liberty and refactored the code to do the following:

  • Break out each shell into own type that defines shell-specific definitions and settings
  • Refactor and rework FormBrowse and settings screen to use the new shell definitions
  • Rework how ConEmu terminal changes folders
  • Remove GitModule.RunBash()

I also made a change that caused the toolbar button to match the shell selection for the ConEmu. I think it fits into the mental model, but the setting location is now in the "wtf?" territory. So I'm somewhat conflicted on this change. We can revert it, if you don't think it is worthwhile change.

Tests are TBD, happy to help (I had only so much time).

@RussKie
Copy link
Member

RussKie commented Jun 14, 2020

Something I didn't get to, but would be good to have - make AppSettings.ConEmuTerminal.ValueOrDefault of type ShellType (represented as int) instead of string. This would allow removal string comparison routines, and remove few allocations.

@RussKie
Copy link
Member

RussKie commented Jun 17, 2020

@pmiossec I'd like to take this into 3.4.2. I have rebased the branch (+1 commit) on to release/3.4 but I was reluctant to push it into your fork. You can see it here - https://github.com/RussKie/gitextensions/tree/launch_shell_consoles

@RussKie RussKie added this to the 3.4.2 milestone Jun 17, 2020
@mstv mstv changed the base branch from master to release/3.4 June 17, 2020 22:16
@mstv mstv changed the base branch from release/3.4 to master June 17, 2020 22:18
@pmiossec
Copy link
Member Author

@RussKie

I'd like to take this into 3.4.2.

Tested. It seems to work well.

Not reviewed because there are a lot of changes and I have to take the time to understand it.
But it seems that the behavior when bash is not found has been changed. On purpose?
Before: a message in the "cmd" console open to tell that bash is not found.
After: (I'm not sure) nothing happens.

I have rebased the branch (+1 commit) on to release/3.4 but I was reluctant to push it into your fork

Go if that's the way forward ;)

@pmiossec pmiossec changed the base branch from master to release/3.4 June 17, 2020 23:35
@pmiossec pmiossec closed this Jun 17, 2020
@pmiossec pmiossec reopened this Jun 17, 2020
@RussKie
Copy link
Member

RussKie commented Jun 18, 2020

Not reviewed because there are a lot of changes and I have to take the time to understand it.

Fair point.
It is easier to review commit-by-commit. The general idea is that each shell is implemented as own type (btw 37b2301, 88ea6d2 and df15749 should be squashed for ease of review).

I have also initially changed how the toolbar item was bound to the same shell selected by a user as a ConEmu default shell. But in the last commit e3c0ed4 I've undone that, as it didn't feel completely coherent with the rest of the change.

But it seems that the behavior when bash is not found has been changed. On purpose?
Before: a message in the "cmd" console open to tell that bash is not found.

I tried to account for a fact that a user may not have all shells available, and only bind shells that user had.
Entirely possible that I may missed some edge case here...

@RussKie RussKie self-assigned this Jun 18, 2020
Copy link
Member Author

@pmiossec pmiossec left a comment

Choose a reason for hiding this comment

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

@RussKie Some discussions ;)

@@ -1505,9 +1505,6 @@ private void RunCommandBasedOnArgument(IReadOnlyList<string> args, IReadOnlyDict
case "formatpatch":
StartFormatPatchDialog();
return;
case "gitbash":
Copy link
Member Author

Choose a reason for hiding this comment

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

You removed a feature from the command line.
Please confirm that it is on purpose because I admit that it should not be often used.
If yes, we have to remove the help line in FormCommandlineHelp.resx

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I did remove it, as I removed GitModule.RunBash() in 14690b0 as it duplicates the functionality of running bash that we have in FormBrowse in a way that is excessive.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. So I pushed the fixup...

Copy link
Member

Choose a reason for hiding this comment

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

I think I got why you removed GitModule.RunBash, @RussKie. But dropping a CLI in this PR feels like a submarine.
It breaks the usecase: bash and e.g. grep not in the PATH, but gitex.cmd in the PATH.
So gitex gitbash should open a bash.

Copy link
Member

@RussKie RussKie Jun 19, 2020

Choose a reason for hiding this comment

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

I mulled over it, and you're probably right - it's a "dot" release, and this could be a breaking behaviour... we can drop 14690b0 from this PR, but I intent do it in the master.

It breaks the usecase: bash and e.g. grep not in the PATH, but gitex.cmd in the PATH.
So gitex gitbash should open a bash.

If bash is not in the path, then we can't open it. Trying to open bash via the app feels wrong.

Copy link
Member

Choose a reason for hiding this comment

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

This removal of the CLI command "gitbash" must be mentioned in the change log.

GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
return CmdShellInstance ?? (CmdShellInstance = new CmdShell());

case "bash":
default:
Copy link
Member Author

Choose a reason for hiding this comment

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

A shellType not found is transformed in a git-bash. Strange...

GitUI/Shells/ShellDescriptor.cs Outdated Show resolved Hide resolved

public IShellDescriptor GetShell(string shellType)
{
switch (shellType.ToLowerInvariant())
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not 100% sold by the introduction of `ShellType' that:

  • seems redundant with names
  • makes (a little) more difficult to add a new shell because you should update 2 places (ShellType and here) and there is no help for the developer if there is a mismatch

The only advantage is to be able to so ShellType.Bash but for this special case, a const could be used.

I will push a commit with a draft in another branch https://github.com/pmiossec/gitextensions/tree/refactor_shells
Please, have a look....

Copy link
Member

Choose a reason for hiding this comment

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

The idea with the enum was to convert the setting to the enum. But your version offers probably equally good alternative.
I left a comment there.

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Jun 19, 2020
@RussKie
Copy link
Member

RussKie commented Jun 21, 2020

Given there are few unresolved and outstanding issues, I'm not going to include this into 3.4.2. On the surface it looked to me as something relatively simple, but few changes may be breaking, thus not fit for a dot release.

@RussKie RussKie modified the milestones: 3.4.2, 4.0 Jun 21, 2020
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Jul 3, 2020
@@ -1505,9 +1505,6 @@ private void RunCommandBasedOnArgument(IReadOnlyList<string> args, IReadOnlyDict
case "formatpatch":
StartFormatPatchDialog();
return;
case "gitbash":
Copy link
Member

Choose a reason for hiding this comment

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

This removal of the CLI command "gitbash" must be mentioned in the change log.

GitUI/Shells/BashShell.cs Show resolved Hide resolved
GitUI/Shells/ConEmuControlExtensions.cs Outdated Show resolved Hide resolved
GitUI/MessageBoxes.cs Outdated Show resolved Hide resolved
GitUI/Shells/ShellProvider.cs Outdated Show resolved Hide resolved
GitUI/Shells/ShellType.cs Outdated Show resolved Hide resolved
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.

Should I prepare a commit with my requested changes to MessageBoxes, @pmiossec?

GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
GitUI/CommandsDialogs/FormBrowse.cs Outdated Show resolved Hide resolved
@pmiossec
Copy link
Member Author

pmiossec commented Jul 5, 2020

Should I prepare a commit with my requested changes to MessageBoxes, @pmiossec?

Yes, it would be great!

@mstv mstv mentioned this pull request Jul 5, 2020
@mstv mstv requested a review from RussKie July 5, 2020 22:33
GitUI/Shells/IShellDescriptor.cs Outdated Show resolved Hide resolved
GitUI/Shells/ConEmuControlExtensions.cs Outdated Show resolved Hide resolved
GitUI/Shells/IShellDescriptor.cs Show resolved Hide resolved
@RussKie
Copy link
Member

RussKie commented Jul 8, 2020

Squash and merge at will

and
- Fix some MessageBox translations
- Refactor shell type system
  * Break out each shell into own type that defines shell-specific defintions and settings
  * Refactor and rework FormBrowse and settings screen to use the new shell definitions
  * Rework how ConEmu terminal changes folders
  * Refactor how shells are intialised:
    Remove Lazy construct, as shells are initialised and iterated over when FormBrowse is loaded anyway.

Co-authored-by: 	RussKie <russkie@gmail.com>
@mstv
Copy link
Member

mstv commented Jul 9, 2020

@msftbot merge in 1 day

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

ghost commented Jul 9, 2020

Hello @mstv!

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, 10 Jul 2020 22:03:47 GMT, which is in 1 day

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".

@mstv mstv changed the base branch from release/3.4 to master July 9, 2020 22:10
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.

Being able to open a powershell or cmd console
4 participants