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

Enhancement: bundle posh-git? #1384

Closed
dahlbyk opened this issue Nov 29, 2017 · 24 comments
Closed

Enhancement: bundle posh-git? #1384

dahlbyk opened this issue Nov 29, 2017 · 24 comments

Comments

@dahlbyk
Copy link

dahlbyk commented Nov 29, 2017

@dscho reached out to me about bundling posh-git with Git for Windows, which I certainly support.

My tentative suggestion would be to have the Git for Windows installer detect a supported PowerShell version (see dahlbyk/posh-git#328 for version support discussion). If available, launch PowerShell to execute a script that runs Install-Module (included in 5.0+, or via PackageManagement PowerShell Modules Preview, if available.

Do you have any way to install it system-wide? (Git for Windows installs system-wide, therefore installing posh-git for the installing user would be a little unfortunate.)

Install-Module accepts a -Scope parameter of either CurrentUser or AllUsers (paths). I assume the Git for Windows installer would be able to spawn an elevated shell to install with AllUsers.

The other part of installation is to inject Import-Module posh-git into a PowerShell profile, which can be one of:

  1. Current User, Current (Default) Host
  2. Current User, All Hosts
  3. All Users, Current (Default) Host
  4. All Users, All Hosts

posh-git's Add-PoshGitToProfile supports -AllHosts but does not support toggling CurrentUser/AllUsers.

Also: what's your release cadence? Would you like to coordinate with Git for Windows releases, or are you fine with me simply picking up the latest posh-git whenever I see a new one?

Release cadence is....infrequent? I'd just let PowerShellGet install the latest for the given platform.

@dscho
Copy link
Member

dscho commented Dec 7, 2017

My tentative suggestion would be to have the Git for Windows installer detect a supported PowerShell version (see dahlbyk/posh-git#328 for version support discussion). If available, launch PowerShell to execute a script that runs Install-Module (included in 5.0+, or via PackageManagement PowerShell Modules Preview, if available.

Sounds good!

I assume the Git for Windows installer would be able to spawn an elevated shell to install with AllUsers.

Yes.

posh-git's Add-PoshGitToProfile supports -AllHosts but does not support toggling CurrentUser/AllUsers.

Is that planned?

Release cadence is....infrequent? I'd just let PowerShellGet install the latest for the given platform.

Makes sense. Either the user updates Git for Windows (and gets the posh-git updates via Install-Module), or the user should update posh-git manually.

@dahlbyk
Copy link
Author

dahlbyk commented Dec 8, 2017

posh-git's Add-PoshGitToProfile supports -AllHosts but does not support toggling CurrentUser/AllUsers.

Is that planned?

dahlbyk/posh-git#504

I'm a month overdue for a release, so I'll ship that soon.

@dscho
Copy link
Member

dscho commented Oct 15, 2021

After running into trouble when e.g. a new Git LFS version came out and users expected a new Git for Windows version to be released just because of that, I think we'll try to learn from that experience a bit and not bundle posh-git.

@dscho dscho closed this as completed Oct 15, 2021
@dahlbyk
Copy link
Author

dahlbyk commented Oct 15, 2021

Well this is embarrassing. As I said:

Release cadence is....infrequent?

posh-git has never been part of my job, and interest/availability ebbs and flows. Squeaky wheels get the grease, so I'll probably get a release out this weekend.

If posh-git is the right technical solution for bundling a PowerShell experience with Git for Windows, let's add maintainers and automate releases to remove me as a bottleneck. Or companies that have benefited from it for a decade could sponsor me to spend more time on it. Or I could transfer ownership and walk away.


The other part of installation is to inject Import-Module posh-git into a PowerShell profile, which can be one of:

  1. Current User, Current (Default) Host
  2. Current User, All Hosts
  3. All Users, Current (Default) Host
  4. All Users, All Hosts

posh-git's Add-PoshGitToProfile supports -AllHosts but does not support toggling CurrentUser/AllUsers.

An -AllUsers flag was added in dahlbyk/posh-git#504.

@dscho
Copy link
Member

dscho commented Oct 15, 2021

Do you still think it'd be a good idea to bundle posh-git in Git for Windows? It would give it a lot of visibility AKA increased maintenance burden...

@dahlbyk
Copy link
Author

dahlbyk commented Oct 16, 2021

Do you still think it'd be a good idea to bundle posh-git in Git for Windows? It would give it a lot of visibility AKA increased maintenance burden...

I think it would be good for Git for Windows to provide/recommend how to do what Git Bash does (prompt, tab completion) in the default Windows shell.

If posh-git is the best option to achieve that, let's figure out how to make that sustainable. Having this goal to work towards might rekindle my interest.

@dscho
Copy link
Member

dscho commented Oct 16, 2021

@dahlbyk so how frequently is posh-git updated (if it really is rarely, I'll gladly reverse my stance)? What is the best way to install it system-wide (I'd like to implement this in InnoSetup, so the ideal for me would be "copy this set of files to that destination, then run this command" or something like that)?

@rimrul
Copy link
Member

rimrul commented Oct 16, 2021

so how frequently is posh-git updated (if it really is rarely, I'll gladly reverse my stance)

Looking at https://github.com/dahlbyk/posh-git/releases, it's roughly once a year (ignoring pre-releases and the occasional two releases on the same day (0.7.0/0.7.1 in april 2017, 0.7.2/0.7.3 in april 2018))

@dscho
Copy link
Member

dscho commented Oct 16, 2021

Okay, once a year-ish is totally doable. The only remaining concern is: are there occasionally vulnerabilities that require coordinated releases?

@dscho
Copy link
Member

dscho commented Oct 18, 2021

Okay, once a year-ish is totally doable. The only remaining concern is: are there occasionally vulnerabilities that require coordinated releases?

I guess I should ping @dahlbyk ;-)

@dahlbyk
Copy link
Author

dahlbyk commented Oct 18, 2021

@dahlbyk so how frequently is posh-git updated (if it really is rarely, I'll gladly reverse my stance)?

Updates could theoretically be as frequent as Git adds commands or command flags, if that were a goal. But actual blocking things like the Git LFS version issue are rare, which is why I've not internalized a sense of urgency to ship releases.

What is the best way to install it system-wide (I'd like to implement this in InnoSetup, so the ideal for me would be "copy this set of files to that destination, then run this command" or something like that)?

Three options to consider:

  1. Install-Module -Scope AllUsers posh-git from the online PSGallery. Probably check if it's installed first and update if found?
  2. Install a bundled posh-git into %ProgramFiles%\Git\pwsh\Modules\posh-git\{version} or equivalent, and Install-Module posh-git -Scope AllUsers -Repository $env:ProgramFiles\Git\pwsh\Modules to copy alongside other system modules.
  3. Update the system $PSModulePath to tack on ;%ProgramFiles%\Git\pwsh\Modules instead. If the user has installed or customized posh-git elsewhere that would take precedence on import (I believe).

The other question is if we should run Add-PoshGitToProfile on behalf of the user, and if so which profile - current user or all users? All hosts or just the default? Maybe that's an option they can choose on install? Nothing works without the module being imported.

Could check how Chocolatey handles this for their module.

Okay, once a year-ish is totally doable. The only remaining concern is: are there occasionally vulnerabilities that require coordinated releases?

I don't know that we've ever had an actual vulnerability reported. The vast majority of what we do is just calling git.

@dscho
Copy link
Member

dscho commented Oct 19, 2021

@dahlbyk great, thanks!

My current thinking is that we should make this a new option (probably a new checkbox just like "Check daily for updates"), and use the PSGallery option, i.e. avoid bundling a specific posh-git version.

Pardon my ignorance, though: what commands would I run to check if it is installed, to find out whether there is a newer version, and what commands would be needed to upgrade if there is a new version?

@rimrul
Copy link
Member

rimrul commented Oct 19, 2021

I assume it's mostly standard Powershell Modules commands, so

to check if it is installed,

Get-InstalledModule -Name posh-git

to find out whether there is a newer version

Find-Module -Name posh-git should return the newest available version

to upgrade if there is a new version?

Update-Module -Name posh-git

@dahlbyk
Copy link
Author

dahlbyk commented Oct 20, 2021

My current thinking is that we should make this a new option (probably a new checkbox just like "Check daily for updates"), and use the PSGallery option, i.e. avoid bundling a specific posh-git version.

I think there are actually two potential settings:

  1. Install system posh-git (and update daily, if selected?)
  2. Include posh-git in profile (which profile?)

2 only makes sense if 1 is selected.

Pardon my ignorance, though: what commands would I run to check if it is installed, to find out whether there is a newer version, and what commands would be needed to upgrade if there is a new version?

@rimrul is correct, though Update-Module is a noop if it's up-to-date so it might not be worth doing a separate find.

Note also that Update-Module will need a -Scope AllUsers just like install.

An edge case we'll need to test is how to behave if the PSGallery isn't marked as trusted. I suppose we could check trust status and reset to untrusted after install if necessary?

@rimrul
Copy link
Member

rimrul commented Oct 20, 2021

An edge case we'll need to test is how to behave if the PSGallery isn't marked as trusted. I suppose we could check trust status and reset to untrusted after install if necessary?

I'd just straight up ask the user if they want to trust PSGallery and then leave it trusted.

I've considered letting powershell ask, but I don't quite understand when it asks that question in a separate window and when it just asks on the console (which the users wont see and would block the installer indefinitely).

Another edge case might be a fresh powershell install where powershell might ask the user to install the nuget provider. (With the same issue of potentially hanging indefinitely)

@dahlbyk
Copy link
Author

dahlbyk commented Oct 20, 2021

I'd just straight up ask the user if they want to trust PSGallery and then leave it trusted.

Another edge case might be a fresh powershell install where powershell might ask the user to install the nuget provider. (With the same issue of potentially hanging indefinitely)

We could even add a note under the checkbox to clarify that choosing this option will ensure the Nuget provider and PSGallery repository will be marked as trusted.

If the user has asked for Git for Windows to auto-update, presumably posh-git should auto-update too?

Implementation-wise I'm assuming this essentially ends up as Install-PoshGit.ps1 and maybe Update-PoshGit.ps1 scripts that ship with the installer. If they ask to install posh-git, the installer would call something like:

powershell.exe -File Install-PoshGit.ps1 -ExecutionPolicy Bypass -NonInteractive -NoProfile

@dscho
Copy link
Member

dscho commented Oct 22, 2021

powershell.exe -File Install-PoshGit.ps1 -ExecutionPolicy Bypass -NonInteractive -NoProfile

Why not use -Command [...] directly?

@dscho dscho reopened this Oct 22, 2021
@dahlbyk
Copy link
Author

dahlbyk commented Oct 22, 2021

powershell.exe -File Install-PoshGit.ps1 -ExecutionPolicy Bypass -NonInteractive -NoProfile

Why not use -Command [...] directly?

I would think a separate script would be easier to test, isolated from the installer? I've never had to ship an installer, so I'm content to defer to what you think would be easier to maintain.

@dscho
Copy link
Member

dscho commented Nov 11, 2021

I would think a separate script would be easier to test, isolated from the installer? I've never had to ship an installer, so I'm content to defer to what you think would be easier to maintain.

I actually find it simpler to put the call directly into the installer. See for example how we call the helper edit-git-bash.exe.

In any case, Git for Windows v2.34.0 is expected to land this coming Monday or Tuesday, and it is a little too late in the cycle for me to be comfortable with including a bigger change such as adding the option to install posh-git into the installer. But right after that version has been released, I am totally in favor of getting this done.

@dscho dscho added this to the After next release milestone Nov 11, 2021
@dahlbyk
Copy link
Author

dahlbyk commented Nov 11, 2021

In any case, Git for Windows v2.34.0 is expected to land this coming Monday or Tuesday, and it is a little too late in the cycle for me to be comfortable with including a bigger change such as adding the option to install posh-git into the installer.

Agreed.

But right after that version has been released, I am totally in favor of getting this done.

👍 I expect to publish a new posh-git release the week of Nov 22.

Let me know what you need from me.

@dscho dscho modified the milestones: v2.34.1, Next release Nov 24, 2021
dscho added a commit to dscho/build-extra that referenced this issue Dec 6, 2021
Posh-Git is a very neat PowerShell module that serves as a PowerShell
equivalent to Git's Bash prompt and tab completion.

Let's offer it as an optional component; When selected, it will be
installed from the PSGallery for all users and will then also be added
to the profile.

This addresses git-for-windows/git#1384

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member

dscho commented Dec 7, 2021

@dahlbyk I've opened a PR over at git-for-windows/build-extra#401, not sure whether you saw it.

Now I have a question: should we uninstall Posh-Git when uninstalling Git for Windows? If so, how do I remove it from the users' profile, programmatically?

@dahlbyk
Copy link
Author

dahlbyk commented Dec 9, 2021

@dahlbyk I've opened a PR over at git-for-windows/build-extra#401, not sure whether you saw it.

🎉 Do you have a target date for 2.35?

Now I have a question: should we uninstall Posh-Git when uninstalling Git for Windows? If so, how do I remove it from the users' profile, programmatically?

Replied over in git-for-windows/build-extra#401 (review).

@rimrul
Copy link
Member

rimrul commented Dec 9, 2021

Do you have a target date for 2.35?

We aim to have Git for Windows releases out within a few days after the corresponding Git release. According to https://tinyurl.com/gitCal Git 2.35.0 is scheduled to release on January 24th.

dscho added a commit to dscho/build-extra that referenced this issue Dec 9, 2021
Posh-Git is a very neat PowerShell module that serves as a PowerShell
equivalent to Git's Bash prompt and tab completion.

Let's offer it as an optional component; When selected, it will be
installed from the PSGallery for all users and will then also be added
to the profile.

When selected, the uninstaller will also uninstall `posh-git`.

This addresses git-for-windows/git#1384

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/build-extra that referenced this issue Dec 9, 2021
Posh-Git is a very neat PowerShell module that serves as a PowerShell
equivalent to Git's Bash prompt and tab completion.

Let's offer it as an optional component; When selected, it will be
installed from the PSGallery for all users and will then also be added
to the profile.

When selected, the uninstaller will also uninstall `posh-git`.

This addresses git-for-windows/git#1384

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/build-extra that referenced this issue Dec 9, 2021
Posh-Git is a very neat PowerShell module that serves as a PowerShell
equivalent to Git's Bash prompt and tab completion.

Let's offer it as an optional component; When selected, it will be
installed from the PSGallery for all users and will then also be added
to the profile.

When selected, the uninstaller will also uninstall `posh-git`.

This addresses git-for-windows/git#1384

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho modified the milestones: v2.35.0, Next release Jan 20, 2022
@dscho dscho removed this from the Next release milestone Mar 22, 2022
@dscho
Copy link
Member

dscho commented Oct 18, 2024

I think it is time to close this, as experience shows that we won't ever get to it.

@dscho dscho closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants