mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Rename Tap#repo_var
to Tap#repo_var_suffix
.
This commit is contained in:
parent
d0a3f09a14
commit
132a87aff5
@ -428,11 +428,11 @@ class Reporter
|
|||||||
@api_names_before_txt = api_names_before_txt
|
@api_names_before_txt = api_names_before_txt
|
||||||
@api_dir_prefix = api_dir_prefix
|
@api_dir_prefix = api_dir_prefix
|
||||||
else
|
else
|
||||||
initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{tap.repo_var}"
|
initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{tap.repo_var_suffix}"
|
||||||
@initial_revision = ENV[initial_revision_var].to_s
|
@initial_revision = ENV[initial_revision_var].to_s
|
||||||
raise ReporterRevisionUnsetError, initial_revision_var if @initial_revision.empty?
|
raise ReporterRevisionUnsetError, initial_revision_var if @initial_revision.empty?
|
||||||
|
|
||||||
current_revision_var = "HOMEBREW_UPDATE_AFTER#{tap.repo_var}"
|
current_revision_var = "HOMEBREW_UPDATE_AFTER#{tap.repo_var_suffix}"
|
||||||
@current_revision = ENV[current_revision_var].to_s
|
@current_revision = ENV[current_revision_var].to_s
|
||||||
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
|
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
|
||||||
end
|
end
|
||||||
|
@ -92,18 +92,17 @@ git_init_if_necessary() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
repo_var() {
|
repo_var_suffix() {
|
||||||
local repo_var
|
local repo_dir="${1}"
|
||||||
|
|
||||||
repo_var="$1"
|
if [[ "${repo_dir}" == "${HOMEBREW_REPOSITORY}" ]]
|
||||||
if [[ "${repo_var}" == "${HOMEBREW_REPOSITORY}" ]]
|
|
||||||
then
|
then
|
||||||
repo_var=""
|
repo_var_suffix=""
|
||||||
else
|
else
|
||||||
repo_var="${repo_var#"${HOMEBREW_LIBRARY}/Taps"}"
|
repo_var_suffix="${repo_dir#"${HOMEBREW_LIBRARY}/Taps"}"
|
||||||
repo_var="$(echo -n "${repo_var}" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
|
repo_var_suffix="$(echo -n "${repo_var_suffix}" | tr -C "A-Za-z0-9" "_" | tr "[:lower:]" "[:upper:]")"
|
||||||
fi
|
fi
|
||||||
echo "${repo_var}"
|
echo "${repo_var_suffix}"
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream_branch() {
|
upstream_branch() {
|
||||||
@ -600,7 +599,7 @@ EOS
|
|||||||
echo "Checking if we need to fetch ${DIR}..."
|
echo "Checking if we need to fetch ${DIR}..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAP_VAR="$(repo_var "${DIR}")"
|
TAP_VAR="$(repo_var_suffix "${DIR}")"
|
||||||
UPSTREAM_BRANCH_DIR="$(upstream_branch)"
|
UPSTREAM_BRANCH_DIR="$(upstream_branch)"
|
||||||
declare UPSTREAM_BRANCH"${TAP_VAR}"="${UPSTREAM_BRANCH_DIR}"
|
declare UPSTREAM_BRANCH"${TAP_VAR}"="${UPSTREAM_BRANCH_DIR}"
|
||||||
declare PREFETCH_REVISION"${TAP_VAR}"="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH_DIR}")"
|
declare PREFETCH_REVISION"${TAP_VAR}"="$(git rev-parse -q --verify refs/remotes/origin/"${UPSTREAM_BRANCH_DIR}")"
|
||||||
@ -774,7 +773,7 @@ EOS
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TAP_VAR="$(repo_var "${DIR}")"
|
TAP_VAR="$(repo_var_suffix "${DIR}")"
|
||||||
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}"
|
UPSTREAM_BRANCH_VAR="UPSTREAM_BRANCH${TAP_VAR}"
|
||||||
UPSTREAM_BRANCH="${!UPSTREAM_BRANCH_VAR}"
|
UPSTREAM_BRANCH="${!UPSTREAM_BRANCH_VAR}"
|
||||||
CURRENT_REVISION="$(read_current_revision)"
|
CURRENT_REVISION="$(read_current_revision)"
|
||||||
|
@ -122,7 +122,7 @@ class Tap
|
|||||||
# Clear internal cache.
|
# Clear internal cache.
|
||||||
def clear_cache
|
def clear_cache
|
||||||
@remote = nil
|
@remote = nil
|
||||||
@repo_var = nil
|
@repo_var_suffix = nil
|
||||||
@formula_dir = nil
|
@formula_dir = nil
|
||||||
@cask_dir = nil
|
@cask_dir = nil
|
||||||
@command_dir = nil
|
@command_dir = nil
|
||||||
@ -175,8 +175,10 @@ class Tap
|
|||||||
"https://github.com/#{full_name}"
|
"https://github.com/#{full_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def repo_var
|
# @private
|
||||||
@repo_var ||= path.to_s
|
sig { returns(String) }
|
||||||
|
def repo_var_suffix
|
||||||
|
@repo_var_suffix ||= path.to_s
|
||||||
.delete_prefix(TAP_DIRECTORY.to_s)
|
.delete_prefix(TAP_DIRECTORY.to_s)
|
||||||
.tr("^A-Za-z0-9", "_")
|
.tr("^A-Za-z0-9", "_")
|
||||||
.upcase
|
.upcase
|
||||||
|
@ -15,8 +15,8 @@ RSpec.describe "brew update-report" do
|
|||||||
def initialize(tap)
|
def initialize(tap)
|
||||||
@tap = tap
|
@tap = tap
|
||||||
|
|
||||||
ENV["HOMEBREW_UPDATE_BEFORE#{tap.repo_var}"] = "12345678"
|
ENV["HOMEBREW_UPDATE_BEFORE#{tap.repo_var_suffix}"] = "12345678"
|
||||||
ENV["HOMEBREW_UPDATE_AFTER#{tap.repo_var}"] = "abcdef00"
|
ENV["HOMEBREW_UPDATE_AFTER#{tap.repo_var_suffix}"] = "abcdef00"
|
||||||
|
|
||||||
super(tap)
|
super(tap)
|
||||||
end
|
end
|
||||||
|
@ -588,4 +588,15 @@ RSpec.describe Tap do
|
|||||||
expect(core_tap.pypi_formula_mappings).to eq formula_list_file_contents
|
expect(core_tap.pypi_formula_mappings).to eq formula_list_file_contents
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#repo_var_suffix" do
|
||||||
|
it "converts the repo directory to an environment variable suffix" do
|
||||||
|
expect(CoreTap.instance.repo_var_suffix).to eq "_HOMEBREW_HOMEBREW_CORE"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "converts non-alphanumeric characters to underscores" do
|
||||||
|
expect(described_class.fetch("my", "tap-with-dashes").repo_var_suffix).to eq "_MY_HOMEBREW_TAP_WITH_DASHES"
|
||||||
|
expect(described_class.fetch("my", "tap-with-@-symbol").repo_var_suffix).to eq "_MY_HOMEBREW_TAP_WITH___SYMBOL"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user