Skip to content

Commit a853f27

Browse files
committed
Apply suggestions form Copilot
1 parent 16215ac commit a853f27

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

lib/tetra/constants.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ module Tetra
55
CCOLLECTIONS = "commons-collections4-4.5.0-M2-src".freeze
66
CHUNK_SEPARATOR_VERSION_MATCHER = /[.\-_ ~,]/ # Constant regex for splitting version chunks
77
LICENSE_MAP_PATH = File.join(__dir__, "data", "license_map.yml").freeze
8+
LICENSE_MAPPINGS = {
9+
"The Apache Software License, Version 2.0" => "Apache-2.0",
10+
"The MIT License" => "MIT",
11+
"Eclipse Public License 1.0" => "EPL-1.0",
12+
"GNU General Public License, version 2" => "GPL-2.0-only",
13+
"GNU Lesser General Public License" => "LGPL-2.1-only",
14+
"Unmapped Custom License" => "Unmapped Custom License"
15+
}.freeze
816
end

spec/lib/coarse/license_detection_spec.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,8 @@ def create_pom(group_id, artifact_id, version, license_name)
2121
XML
2222
end
2323

24-
let(:test_cases) do
25-
{
26-
"The Apache Software License, Version 2.0" => "Apache-2.0",
27-
"The MIT License" => "MIT",
28-
"Eclipse Public License 1.0" => "EPL-1.0",
29-
"GNU General Public License, version 2" => "GPL-2.0-only",
30-
"GNU Lesser General Public License" => "LGPL-2.1-only",
31-
"Unmapped Custom License" => "Unmapped Custom License"
32-
}
33-
end
34-
35-
it "detects license names and converts them to SPDX" do
36-
test_cases.each do |raw_name, expected_spdx|
24+
Tetra::LICENSE_MAPPINGS.each do |raw_name, expected_spdx|
25+
it "correctly maps '#{raw_name}' to '#{expected_spdx}'" do
3726
project_name = "proj-#{expected_spdx.downcase.gsub(/[^a-z0-9]/, "")}"
3827
version = "1.0"
3928
group_id = "com.example"
@@ -49,19 +38,19 @@ def create_pom(group_id, artifact_id, version, license_name)
4938
run_command_and_stop("tetra init #{project_name} #{tarball_name}")
5039

5140
cd(project_name) do
41+
# Note: Identity is already set in spec_helper's around hook,
42+
# but we can keep these for explicit project-level config
5243
run_command_and_stop("git config user.email 'test@example.com'")
5344
run_command_and_stop("git config user.name 'Test User'")
5445

5546
# --- NON-INTERACTIVE DRY-RUN ---
56-
# We use a heredoc to pipe the commands directly.
5747
run_command("tetra dry-run")
5848
last_command_started.write <<~COMMANDS
5949
touch #{project_name}-#{version}.jar
6050
echo 'changes' >> README
6151
exit 0
6252
COMMANDS
6353

64-
# Stop will wait for the pipe to close and the process to exit naturally
6554
last_command_started.stop
6655
expect(last_command_started).to be_successfully_executed
6756

spec/spec_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
bin_path = File.expand_path(File.join(__dir__, "..", "bin"))
3939

40+
# Apply changes to global ENV (affects Ruby unit tests)
41+
# Subprocesses spawned by Aruba inherit this modified PATH automatically
4042
ENV["PATH"] = "#{bin_path}#{File::PATH_SEPARATOR}#{original_env["PATH"]}"
4143
ENV["GIT_AUTHOR_NAME"] = "Tetra Test"
4244
ENV["GIT_AUTHOR_EMAIL"] = "test@example.com"
@@ -45,9 +47,7 @@
4547

4648
# Apply changes to Aruba (affects subprocesses/coarse tests)
4749
if respond_to?(:set_environment_variable)
48-
# NOTE: set_environment_variable overwrites
49-
# prepend_environment_variable appends
50-
prepend_environment_variable("PATH", bin_path + File::PATH_SEPARATOR)
50+
# NOTE: set_environment_variable overwrites.
5151
set_environment_variable("GIT_AUTHOR_NAME", "Tetra Test")
5252
set_environment_variable("GIT_AUTHOR_EMAIL", "test@example.com")
5353
set_environment_variable("GIT_COMMITTER_NAME", "Tetra Test")

0 commit comments

Comments
 (0)