Skip to content

Conversation

@abgox
Copy link

@abgox abgox commented Sep 28, 2025

Summary by CodeRabbit

  • New Features

    • Installer can clone core resources from Git repositories, falling back to ZIP downloads if cloning fails.
    • New options exposed to point the installer at Git-based package and bucket sources.
  • Changed

    • Configuration now resides under the installation directory by default (config file path updated).

@coderabbitai
Copy link

coderabbitai bot commented Sep 28, 2025

Walkthrough

Replaces XDG/USERPROFILE-based config path with SCOOP_DIR-derived SCOOP_CONFIG_HOME/SCOOP_CONFIG_FILE. Adds two new public variables SCOOP_PACKAGE_GIT_REPO and SCOOP_MAIN_BUCKET_GIT_REPO. Installer now attempts Git clone first and falls back to ZIP download if cloning fails.

Changes

Cohort / File(s) Change Summary
Installer bootstrap
install.ps1
- SCOOP_CONFIG_HOME and SCOOP_CONFIG_FILE now derive from SCOOP_DIR instead of XDG/USERPROFILE
- Added public vars: SCOOP_PACKAGE_GIT_REPO, SCOOP_MAIN_BUCKET_GIT_REPO
- Bootstrap flow: try Git clone (if git/repos provided); on clone failure, fallback to ZIP download flow

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant I as install.ps1
  participant G as Git Host
  participant Z as Zip Host

  U->>I: Run installer
  rect rgba(240,240,255,0.6)
    I->>I: Resolve config paths\nif SCOOP_DIR -> SCOOP_CONFIG_HOME=SCOOP_DIR\nSCOOP_CONFIG_FILE=SCOOP_DIR\config.json\nelse -> use XDG/USERPROFILE
  end

  rect rgba(235,255,235,0.6)
    I->>G: Attempt clone `SCOOP_PACKAGE_GIT_REPO` (if set & git available)
    alt clone succeeds
      I->>G: Clone `SCOOP_MAIN_BUCKET_GIT_REPO` (if set)
    else clone fails
      I->>Z: Download package ZIP (`SCOOP_PACKAGE_REPO`)
      I->>Z: Download main bucket ZIP (`SCOOP_MAIN_BUCKET_REPO`)
    end
  end

  I-->>U: Bootstrap complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through scripts with whiskers bright,
Git first, then zip if cloning's slight—
Paths now snug where SCOOP likes to stay,
I fetch the buckets, then bound away. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: use portable config" clearly and concisely highlights the primary change of deriving configuration paths from a single SCOOP_DIR for portability, which aligns directly with the adjustment to SCOOP_CONFIG_HOME and SCOOP_CONFIG_FILE in the pull request. It avoids unnecessary detail while signaling the introduction of a new feature, making it understandable to reviewers scanning the project history. The title is specific enough to convey the key intent without overloading on secondary changes such as Git repository support.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0faf2d8 and da42fb0.

📒 Files selected for processing (1)
  • install.ps1 (1 hunks)
🔇 Additional comments (1)
install.ps1 (1)

697-700: Portable-config mode now always enabled

After Line 685 we already guarantee $SCOOP_DIR is a non-empty string (defaults to $env:USERPROFILE\scoop), so Lines 699-700 now force every install to write config.json into the scoop root. That regresses the long-standing default of storing config in $XDG_CONFIG_HOME\scoop\config.json or %USERPROFILE%\.config\scoop\config.json unless the caller explicitly asked for a portable layout. Please gate the portable path behind an explicit signal (parameter or env var) and fall back to the prior per-user path otherwise.

Apply this diff to restore the intended behavior:

-$SCOOP_CONFIG_HOME = $SCOOP_DIR
-$SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
+$usePortableConfig = $PSBoundParameters.ContainsKey('ScoopDir') -or -not [string]::IsNullOrEmpty($env:SCOOP)
+if ($usePortableConfig) {
+    $SCOOP_CONFIG_HOME = $SCOOP_DIR
+    $SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
+} else {
+    $SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" |
+        Where-Object { -not [string]::IsNullOrEmpty($_) } |
+        Select-Object -First 1
+    $SCOOP_CONFIG_FILE = "$SCOOP_CONFIG_HOME\scoop\config.json"
+}

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
install.ps1 (1)

595-603: Git clone path is missing parent directories

Line 595 calls git clone before ensuring that $SCOOP_APP_DIR/$SCOOP_MAIN_BUCKET_DIR parents exist. On a clean machine apps\scoop and buckets aren’t there yet, so Git fails with “could not create leading directories…”, and we always fall back to the zip path. Please create the parent folders first so the new Git bootstrap actually succeeds.

+            $appParentDir = Split-Path -Parent $SCOOP_APP_DIR
+            if (!(Test-Path $appParentDir)) {
+                New-Item -ItemType Directory -Path $appParentDir -Force | Out-Null
+            }
+            $mainBucketParentDir = Split-Path -Parent $SCOOP_MAIN_BUCKET_DIR
+            if (!(Test-Path $mainBucketParentDir)) {
+                New-Item -ItemType Directory -Path $mainBucketParentDir -Force | Out-Null
+            }
             Write-Verbose "Cloning $SCOOP_PACKAGE_GIT_REPO to $SCOOP_APP_DIR"
             git clone -q $SCOOP_PACKAGE_GIT_REPO $SCOOP_APP_DIR
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff4eedd and 0faf2d8.

📒 Files selected for processing (1)
  • install.ps1 (1 hunks)

install.ps1 Outdated
Comment on lines 697 to 703
if ($SCOOP_DIR) {
$SCOOP_CONFIG_HOME = $SCOOP_DIR
$SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
} else {
$SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
$SCOOP_CONFIG_FILE = "$SCOOP_CONFIG_HOME\scoop\config.json"
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Portable-config condition always triggers

Because Line 685 already guarantees $SCOOP_DIR is a non-empty string (it falls back to $env:USERPROFILE\scoop), the new if ($SCOOP_DIR) branch always runs. That means every install now writes config.json into $SCOOP_DIR, breaking the previous default of $XDG_CONFIG_HOME\scoop\config.json/%USERPROFILE%\.config\scoop\config.json. We only want the portable layout when the caller explicitly set ScoopDir or $env:SCOOP.

-if ($SCOOP_DIR) {
+$usePortableConfig = $PSBoundParameters.ContainsKey('ScoopDir') -or -not [string]::IsNullOrEmpty($env:SCOOP)
+if ($usePortableConfig) {
     $SCOOP_CONFIG_HOME = $SCOOP_DIR
     $SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
 } else {
     $SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
     $SCOOP_CONFIG_FILE = "$SCOOP_CONFIG_HOME\scoop\config.json"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ($SCOOP_DIR) {
$SCOOP_CONFIG_HOME = $SCOOP_DIR
$SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
} else {
$SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
$SCOOP_CONFIG_FILE = "$SCOOP_CONFIG_HOME\scoop\config.json"
}
# only use the "portable" config layout when ScoopDir was passed or $env:SCOOP is set
$usePortableConfig = $PSBoundParameters.ContainsKey('ScoopDir') -or -not [string]::IsNullOrEmpty($env:SCOOP)
if ($usePortableConfig) {
$SCOOP_CONFIG_HOME = $SCOOP_DIR
$SCOOP_CONFIG_FILE = "$SCOOP_DIR\config.json"
} else {
$SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
$SCOOP_CONFIG_FILE = "$SCOOP_CONFIG_HOME\scoop\config.json"
}
🤖 Prompt for AI Agents
In install.ps1 around lines 697 to 703, the current if ($SCOOP_DIR) always
evaluates true because $SCOOP_DIR was earlier defaulted, so change the condition
to only use the portable layout when the caller explicitly set ScoopDir or
$env:SCOOP; replace the if with a check like: if ($env:SCOOP -or
($PSBoundParameters.ContainsKey('ScoopDir'))) { ... } else { ... } so that when
neither the env var nor the script parameter was provided the script falls back
to XDG/USERPROFILE config paths.

@abgox abgox force-pushed the use-portable-config branch from 0faf2d8 to da42fb0 Compare September 28, 2025 01:02
@abgox
Copy link
Author

abgox commented Sep 28, 2025

Since Scoop supports portable configurations, it should be used by default, as it is more in line with Scoop.

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.

1 participant