Skip to content

Enhancement: bundle posh-git? #1384

Closed as not planned
Closed as not planned

Description

@dahlbyk

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

Activity

  1. dscho commented on Dec 7, 2017

    @dscho
    Member

    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.

  2. dahlbyk commented on Dec 8, 2017

    @dahlbyk
    Author

    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.

  3. dscho commented on Oct 15, 2021

    @dscho
    Member

    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.

  4. dahlbyk commented on Oct 15, 2021

    @dahlbyk
    Author

    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.

  5. dscho commented on Oct 15, 2021

    @dscho
    Member

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

  6. dahlbyk commented on Oct 16, 2021

    @dahlbyk
    Author

    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.

  7. dscho commented on Oct 16, 2021

    @dscho
    Member

    @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)?

  8. rimrul commented on Oct 16, 2021

    @rimrul
    Member

    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))

  9. dscho commented on Oct 16, 2021

    @dscho
    Member

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

  10. dscho commented on Oct 18, 2021

    @dscho
    Member

    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 ;-)

  11. dahlbyk commented on Oct 18, 2021

    @dahlbyk
    Author

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

  12. dscho commented on Oct 19, 2021

    @dscho
    Member

    @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?

  13. rimrul commented on Oct 19, 2021

    @rimrul
    Member

    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

  14. dahlbyk commented on Oct 20, 2021

    @dahlbyk
    Author

    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?

  15. 7 remaining items

  16. dahlbyk commented on Nov 11, 2021

    @dahlbyk
    Author

    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.

  17. modified the milestones: v2.34.1, Next release on Nov 24, 2021
  18. added a commit that references this issue on Dec 6, 2021
  19. dscho commented on Dec 7, 2021

    @dscho
    Member

    @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?

  20. dahlbyk commented on Dec 9, 2021

    @dahlbyk
    Author

    @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).

  21. rimrul commented on Dec 9, 2021

    @rimrul
    Member

    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.

  22. modified the milestones: v2.35.0, Next release on Jan 20, 2022
  23. removed this from the Next release milestone on Mar 22, 2022
  24. dscho commented on Oct 18, 2024

    @dscho
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions