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

Add the Remove-PoshGitFromProfile function #877

Merged
merged 7 commits into from
Mar 31, 2022

Conversation

dscho
Copy link
Contributor

@dscho dscho commented Dec 10, 2021

This is needed to be able to install/uninstall Posh-Git via Git for Windows' installer/uninstaller.

See git-for-windows/build-extra#401 for details.

This is needed to be able to install/uninstall Posh-Git via Git for
Windows' installer/uninstaller.

See git-for-windows/build-extra#401 for details.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Contributor Author

dscho commented Dec 10, 2021

Please note that the CI failures are independent of the changes introduced by this here PR. At least some of them seem to have been reported before.

@dscho
Copy link
Contributor Author

dscho commented Jan 6, 2022

@dahlbyk ping?

@dscho
Copy link
Contributor Author

dscho commented Jan 9, 2022

Sorry to be a bother, but if we want to offer Posh-Git as an option in Git for Windows v2.35.0, we kinda need to move a little faster ;-)

src/Utils.ps1 Outdated Show resolved Hide resolved
src/Utils.ps1 Outdated Show resolved Hide resolved
src/Utils.ps1 Outdated
Comment on lines 314 to 332
$oldProfile = @(Get-Content $profilePath)

. $currentVersionPath\src\Utils.ps1
$oldProfileEncoding = Get-FileEncoding $profilePath

$newProfile = @()
foreach($line in $oldProfile) {
if ($line -like '*PoshGitPrompt*') { continue; }
if ($line -like '*Load posh-git example profile*') { continue; }

if($line -like '. *posh-git*profile.example.ps1*') {
continue;
}
if($line -like 'Import-Module *\posh-git.psd1*') {
continue;
}
$newProfile += $line
}
Set-Content -path $profilePath -value $newProfile -Force -Encoding $oldProfileEncoding
Copy link
Owner

Choose a reason for hiding this comment

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

Noting this is pulled from:

$oldProfile = @(Get-Content $PROFILE)
. $currentVersionPath\src\Utils.ps1
$oldProfileEncoding = Get-FileEncoding $PROFILE
$newProfile = @()
foreach($line in $oldProfile) {
if ($line -like '*PoshGitPrompt*') { continue; }
if ($line -like '*Load posh-git example profile*') { continue; }
if($line -like '. *posh-git*profile.example.ps1*') {
continue;
}
if($line -like 'Import-Module *\src\posh-git.psd1*') {
continue;
}
$newProfile += $line
}
Set-Content -path $profile -value $newProfile -Force -Encoding $oldProfileEncoding

Will be nice to use this function there.

@dahlbyk dahlbyk merged commit 7764b4f into dahlbyk:master Mar 31, 2022
@dscho dscho deleted the Remove-PoshGitFromProfile branch March 31, 2022 11:53
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

Successfully merging this pull request may close these issues.

2 participants