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

feat: Support using external git for initialization #40

Merged
merged 4 commits into from
Mar 16, 2023

Conversation

xxthunder
Copy link
Contributor

@xxthunder xxthunder commented Jan 23, 2023

  • install.ps1 uses git for retrieval of Scoop and Main repo instead of downloading the zips.
  • CI workflow runs install.ps1 and tests scoop availability after installation.

@xxthunder
Copy link
Contributor Author

Our company's proxy forbids downloading the zipped repos (see ScoopInstaller/Scoop#5012 for details). So my workaround is to use 'git clone' instead when git is already installed (which is the case on our engineering machines). No idea if this is worth merging. Maybe it helps someone out there. 😄

@chawyehsu
Copy link
Member

chawyehsu commented Jan 27, 2023

I don't mind leveraging the existing git command for bucket initialization. Still, similar to the downloader, you will need to pass potential proxy configs -NoProxy, -Proxy, -ProxyCredential, and -ProxyUseDefaultCredentials to git, so it can follow the proxy strategy when doing clones.

@xxthunder
Copy link
Contributor Author

@chawyehsu Thank you very much for your feedback. Currently we are using environment variables for doing this: HTTP_PROXY, HTTPS_PROXY and NO_PROXY. So no need for command line arguments.

@chawyehsu
Copy link
Member

That's perfectly fine when you are using proxy environment variables, what I mean is if you do not pass those proxy settings to the git command, then other users who use irm get.scoop.sh -Proxy 'http://<ip:port>' | iex to install Scoop without configuring proxy environment variables will not be able to clone/initialize buckets because git is not configured to use the prxoy -Proxy 'http://<ip:port>'.

Install/install.ps1

Lines 43 to 50 in f1cf244

.PARAMETER NoProxy
Bypass system proxy during the installation.
.PARAMETER Proxy
Specifies proxy to use during the installation.
.PARAMETER ProxyCredential
Specifies credential for the given prxoy.
.PARAMETER ProxyUseDefaultCredentials
Use the credentials of the current user for the proxy server that is specified by the -Proxy parameter.

Install/install.ps1

Lines 175 to 199 in f1cf244

function Get-Downloader {
$downloadSession = New-Object System.Net.WebClient
# Set proxy to null if NoProxy is specificed
if ($NoProxy) {
$downloadSession.Proxy = $null
} elseif ($Proxy) {
# Prepend protocol if not provided
if (!$Proxy.IsAbsoluteUri) {
$Proxy = New-Object System.Uri("http://" + $Proxy.OriginalString)
}
$Proxy = New-Object System.Net.WebProxy($Proxy)
if ($null -ne $ProxyCredential) {
$Proxy.Credentials = $ProxyCredential.GetNetworkCredential()
} elseif ($ProxyUseDefaultCredentials) {
$Proxy.UseDefaultCredentials = $true
}
$downloadSession.Proxy = $Proxy
}
return $downloadSession
}

@xxthunder
Copy link
Contributor Author

Aaah, yes, now I got your point. Looking into it, will come back to you.

install.ps1 Outdated Show resolved Hide resolved
@xxthunder xxthunder force-pushed the master branch 4 times, most recently from 95bf694 to 418f611 Compare February 7, 2023 12:59
@xxthunder
Copy link
Contributor Author

xxthunder commented Feb 7, 2023

Okay, got the scoop installer and finally scoop running in GitHub action to see that it is actually working. @chawyehsu Any feedback is welcome.

By the way, green finally: https://github.com/xxthunder/ScoopInstall/actions/runs/4114136831

install.ps1 Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@xxthunder
Copy link
Contributor Author

xxthunder commented Mar 8, 2023

@chawyehsu Finally found some time again. Thanks for pointing me to this Invoke-Git function. So I took over the env vars recovery. Tests are green: https://github.com/xxthunder/ScoopInstall/actions/runs/4368498689

Please review again when you have time.

@xxthunder xxthunder force-pushed the master branch 2 times, most recently from ce5051a to 05afedb Compare March 8, 2023 21:36
@xxthunder xxthunder requested a review from chawyehsu March 9, 2023 07:27
@chawyehsu chawyehsu changed the title Use git for installation when available already feat: Support using external git for initialization Mar 16, 2023
@chawyehsu chawyehsu merged commit 1375d9e into ScoopInstaller:master Mar 16, 2023
@chawyehsu
Copy link
Member

Thank you for your contributions! 🎉

BeforeAll {
# Load SUT
$sut = (Split-Path -Leaf $PSCommandPath).Replace('.Tests.ps1', '.ps1')
. ".\$sut"
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed this will actually trigger an installation of Scoop, it tries to expose functions for unit tests below but it imports the whole install script. I noticed it when implementing #76 and the ci kept failing. ;p

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