From 890e7ab9a8e5b32fb017c01174ad9020e2cc06b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Sep 2025 12:58:04 +0000 Subject: [PATCH] Finalize XDG support with proper backwards compatibility Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com> --- Library/Homebrew/bundle/brewfile.rb | 2 +- Library/Homebrew/test/bundle/brewfile_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/bundle/brewfile.rb b/Library/Homebrew/bundle/brewfile.rb index 2b139e4900..77354a6828 100644 --- a/Library/Homebrew/bundle/brewfile.rb +++ b/Library/Homebrew/bundle/brewfile.rb @@ -28,7 +28,7 @@ module Homebrew # In bin/brew: XDG_CONFIG_HOME set -> HOMEBREW_USER_CONFIG_HOME="${XDG_CONFIG_HOME}/homebrew" # XDG_CONFIG_HOME not set -> HOMEBREW_USER_CONFIG_HOME="${HOME}/.homebrew" using_xdg = user_config_home&.end_with?("/homebrew") - + if using_xdg && user_config_home # XDG mode: check both XDG and legacy locations, preferring existing files xdg_brewfile = "#{user_config_home}/Brewfile" diff --git a/Library/Homebrew/test/bundle/brewfile_spec.rb b/Library/Homebrew/test/bundle/brewfile_spec.rb index 279def04b9..a8bcf75c58 100644 --- a/Library/Homebrew/test/bundle/brewfile_spec.rb +++ b/Library/Homebrew/test/bundle/brewfile_spec.rb @@ -29,8 +29,9 @@ RSpec.describe Homebrew::Bundle::Brewfile do allow(ENV).to receive(:[]).with("XDG_CONFIG_HOME").and_return(nil) allow(File).to receive(:exist?).with("/Users/username/.homebrew/Brewfile") .and_return(config_dir_brewfile_exist) - # Allow any other File.exist? calls to return false by default + # Allow any other File.exist? calls and Dir.home calls for flexibility allow(File).to receive(:exist?).and_return(false) + allow(Dir).to receive(:home).and_return("/Users/username") end context "when `file` is specified with a relative path" do