- Fixed local filesystem scans to keep open_path_as_is enabled when opening Git repositories and only disable it for diff-based scans.

- Created Linux and Windows specific installer script
- Updated diff-focused scanning so --branch-root-commit can be provided alongside --branch, letting you diff from a chosen commit while targeting a specific branch tip (still defaulting back to the --branch ref when the commit is omitted).
This commit is contained in:
Mick Grove 2025-10-25 17:12:51 -07:00
commit 7d9d3be132
23 changed files with 1608 additions and 21 deletions

View file

@ -0,0 +1,80 @@
<#
.SYNOPSIS
Download and install the latest Kingfisher release for Windows.
.DESCRIPTION
Fetches the most recent GitHub release for mongodb/kingfisher, downloads the
Windows x64 archive, and extracts kingfisher.exe to the destination folder.
By default the script installs into "$env:USERPROFILE\bin".
.PARAMETER InstallDir
Optional destination directory for the kingfisher.exe binary.
.EXAMPLE
./install-kingfisher.ps1
.EXAMPLE
./install-kingfisher.ps1 -InstallDir "C:\\Tools"
#>
param(
[Parameter(Position = 0)]
[string]$InstallDir = (Join-Path $env:USERPROFILE 'bin')
)
$repo = 'mongodb/kingfisher'
$apiUrl = "https://api.github.com/repos/$repo/releases/latest"
$assetName = 'kingfisher-windows-x64.zip'
if (-not (Get-Command Invoke-WebRequest -ErrorAction SilentlyContinue)) {
throw 'Invoke-WebRequest is required to download releases.'
}
if (-not (Get-Command Expand-Archive -ErrorAction SilentlyContinue)) {
throw 'Expand-Archive is required to extract the release archive. Install the PowerShell archive module.'
}
Write-Host "Fetching latest release metadata for $repo"
try {
$response = Invoke-WebRequest -Uri $apiUrl -UseBasicParsing
$release = $response.Content | ConvertFrom-Json
} catch {
throw "Failed to retrieve release information from GitHub: $_"
}
$releaseTag = $release.tag_name
$asset = $release.assets | Where-Object { $_.name -eq $assetName }
if (-not $asset) {
throw "Could not find asset '$assetName' in the latest release."
}
$tempDir = New-Item -ItemType Directory -Path ([System.IO.Path]::GetTempPath()) -Name ([System.Guid]::NewGuid().ToString())
$archivePath = Join-Path $tempDir.FullName $assetName
try {
if ($releaseTag) {
Write-Host "Latest release: $releaseTag"
}
Write-Host "Downloading $assetName"
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $archivePath -UseBasicParsing
Write-Host 'Extracting archive…'
Expand-Archive -Path $archivePath -DestinationPath $tempDir.FullName -Force
$binaryPath = Join-Path $tempDir.FullName 'kingfisher.exe'
if (-not (Test-Path $binaryPath)) {
throw 'Extracted archive did not contain kingfisher.exe.'
}
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
$destination = Join-Path $InstallDir 'kingfisher.exe'
Copy-Item -Path $binaryPath -Destination $destination -Force
Write-Host "Kingfisher installed to: $destination"
Write-Host "Ensure '$InstallDir' is in your PATH environment variable."
}
finally {
if ($tempDir -and (Test-Path $tempDir.FullName)) {
Remove-Item -Path $tempDir.FullName -Recurse -Force
}
}

151
scripts/install-kingfisher.sh Executable file
View file

@ -0,0 +1,151 @@
#!/usr/bin/env bash
set -euo pipefail
REPO="mongodb/kingfisher"
API_URL="https://api.github.com/repos/${REPO}/releases/latest"
DEFAULT_INSTALL_DIR="$HOME/.local/bin"
usage() {
cat <<'USAGE'
Usage: install-kingfisher.sh [INSTALL_DIR]
Downloads the latest Kingfisher release for Linux or macOS and installs the
binary into INSTALL_DIR (default: ~/.local/bin).
The script requires curl, tar, and python3.
USAGE
}
if [[ "${1-}" == "-h" || "${1-}" == "--help" ]]; then
usage
exit 0
fi
INSTALL_DIR="${1:-$DEFAULT_INSTALL_DIR}"
if ! command -v curl >/dev/null 2>&1; then
echo "Error: curl is required to download releases." >&2
exit 1
fi
if ! command -v tar >/dev/null 2>&1; then
echo "Error: tar is required to extract the release archive." >&2
exit 1
fi
if ! command -v python3 >/dev/null 2>&1; then
echo "Error: python3 is required to process the GitHub API response." >&2
exit 1
fi
OS=$(uname -s)
ARCH=$(uname -m)
case "$OS" in
Linux)
platform="linux"
;;
Darwin)
platform="darwin"
;;
*)
echo "Error: Unsupported operating system '$OS'." >&2
echo "This installer currently supports Linux and macOS." >&2
exit 1
;;
esac
case "$ARCH" in
x86_64|amd64)
arch_suffix="x64"
;;
arm64|aarch64)
arch_suffix="arm64"
;;
*)
echo "Error: Unsupported architecture '$ARCH'." >&2
echo "This installer currently supports x86_64/amd64 and arm64/aarch64." >&2
exit 1
;;
esac
asset_name="kingfisher-${platform}-${arch_suffix}.tgz"
echo "Fetching latest release metadata for ${REPO}"
release_json=$(curl -fsSL "$API_URL")
if [[ -z "$release_json" ]]; then
echo "Error: Failed to retrieve release information from GitHub." >&2
exit 1
fi
download_url=$(RELEASE_JSON="$release_json" python3 - "$asset_name" <<'PY'
import json
import sys
import os
asset_name = sys.argv[1]
try:
release = json.loads(os.environ["RELEASE_JSON"])
except (json.JSONDecodeError, KeyError) as exc:
sys.stderr.write(f"Error: Failed to parse GitHub response: {exc}\n")
sys.exit(1)
for asset in release.get("assets", []):
if asset.get("name") == asset_name:
print(asset.get("browser_download_url", ""))
sys.exit(0)
sys.stderr.write(f"Error: Could not find asset '{asset_name}' in the latest release.\n")
sys.exit(1)
PY
)
if [[ -z "$download_url" ]]; then
exit 1
fi
release_tag=$(RELEASE_JSON="$release_json" python3 - <<'PY'
import json
import sys
import os
try:
release = json.loads(os.environ["RELEASE_JSON"])
except (json.JSONDecodeError, KeyError) as exc:
sys.stderr.write(f"Error: Failed to parse GitHub response: {exc}\n")
sys.exit(1)
print(release.get("tag_name", ""))
PY
)
tmpdir=$(mktemp -d)
cleanup() {
rm -rf "$tmpdir"
}
trap cleanup EXIT
archive_path="$tmpdir/$asset_name"
if [[ -n "$release_tag" ]]; then
echo "Latest release: $release_tag"
fi
echo "Downloading $asset_name"
curl -fsSL "$download_url" -o "$archive_path"
echo "Extracting archive…"
tar -C "$tmpdir" -xzf "$archive_path"
if [[ ! -f "$tmpdir/kingfisher" ]]; then
echo "Error: Extracted archive did not contain the kingfisher binary." >&2
exit 1
fi
mkdir -p "$INSTALL_DIR"
install -m 755 "$tmpdir/kingfisher" "$INSTALL_DIR/kingfisher"
printf 'Kingfisher installed to: %s/kingfisher\n\n' "$INSTALL_DIR"
printf 'Add the following to your shell configuration if the directory is not already in your PATH:\n export PATH="%s:$PATH"\n' "$INSTALL_DIR"