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

Rename checkver_token to gh_token and SCOOP_CHECKVER_TOKEN to SCOOP_GH_TOKEN #4832

Merged
merged 2 commits into from Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

### Features

- **install:** Allow downloading from private repositories ([$4254](https://github.com/ScoopInstaller/Scoop/issues/4243))
- **install:** Allow downloading from private repositories ([#4254](https://github.com/ScoopInstaller/Scoop/issues/4243))
- **config:** Rename checkver_token to gh_token and SCOOP_CHECKVER_TOKEN to SCOOP_GH_TOKEN ([#4832](https://github.com/ScoopInstaller/Scoop/pull/4832))

### Bug Fixes

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ $env:SCOOP_CACHE='F:\ScoopCache'
# run the installer
```

### Configure Scoop to use a GitHub API token during searching and checkver by setting `SCOOP_CHECKVER_TOKEN`
### Configure Scoop to use a GitHub API token during searching and checkver by setting `SCOOP_GH_TOKEN`

```powershell
$env:SCOOP_CHECKVER_TOKEN='<paste-token-here>'
[Environment]::SetEnvironmentVariable('SCOOP_CHECKVER_TOKEN', $env:SCOOP_CHECKVER_TOKEN, 'Machine')
$env:SCOOP_GH_TOKEN='<paste-token-here>'
[Environment]::SetEnvironmentVariable('SCOOP_GH_TOKEN', $env:SCOOP_GH_TOKEN, 'Machine')
# search for an app
```

Expand Down
2 changes: 1 addition & 1 deletion bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ param(

$Dir = Resolve-Path $Dir
$Search = $App
$GitHubToken = $env:SCOOP_CHECKVER_TOKEN, (get_config 'checkver-token') | Where-Object -Property Length -Value 0 -GT | Select-Object -First 1
$GitHubToken = $env:SCOOP_GH_TOKEN, (get_config 'gh_token') | Where-Object -Property Length -Value 0 -GT | Select-Object -First 1

# don't use $Version with $App = '*'
if ($App -eq '*' -and $Version -ne '') {
Expand Down
2 changes: 1 addition & 1 deletion lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ function handle_special_urls($url)
}

# Github.com
if ($url -match 'github.com/(?<owner>[^/]+)/(?<repo>[^/]+)/releases/download/(?<tag>[^/]+)/(?<file>[^/#]+)(?<filename>.*)' -and ($token = get_config 'checkver_token')) {
if ($url -match 'github.com/(?<owner>[^/]+)/(?<repo>[^/]+)/releases/download/(?<tag>[^/]+)/(?<file>[^/#]+)(?<filename>.*)' -and ($token = get_config 'gh_token')) {
$headers = @{ "Authorization" = "token $token" }
$privateUrl = "https://api.github.com/repos/$($Matches.owner)/$($Matches.repo)"
$assetUrl = "https://api.github.com/repos/$($Matches.owner)/$($Matches.repo)/releases/tags/$($Matches.tag)"
Expand Down
4 changes: 2 additions & 2 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ function dl($url, $to, $cookies, $progress) {
}
if ($url -match 'api\.github\.com/repos') {
$wreq.Accept = 'application/octet-stream'
$wreq.Headers['Authorization'] = "token $(get_config 'checkver_token')"
$wreq.Headers['Authorization'] = "token $(get_config 'gh_token')"
}
if ($cookies) {
$wreq.Headers.Add('Cookie', (cookie_header $cookies))
}

get_config 'private_hosts' | Where-Object { $url -match $_.match } | ForEach-Object {
get_config 'private_hosts' | Where-Object { $_ -ne $null -and $url -match $_.match } | ForEach-Object {
(ConvertFrom-StringData -StringData $_.Headers).GetEnumerator() | ForEach-Object {
$wreq.Headers[$_.Key] = $_.Value
}
Expand Down
2 changes: 1 addition & 1 deletion libexec/scoop-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# cachePath:
# For downloads, defaults to 'cache' folder under Scoop root directory.
#
# checkver_token:
# gh_token:
# GitHub API token used to make authenticated requests.
# This is essential for checkver and similar functions to run without
# incurring rate limits and download from private repositories.
Expand Down