omf.packages.name: Fix regex by escaping a dot

Fix #901
This commit is contained in:
Pablo Santiago Blum de Aguiar 2022-05-31 21:14:44 +02:00 committed by Pablo Santiago Blum de Aguiar
parent dc9d2c32d5
commit 0eeacf0684
2 changed files with 78 additions and 1 deletions

View File

@ -1,3 +1,3 @@
function omf.packages.name -a name_or_url function omf.packages.name -a name_or_url
command basename $name_or_url | sed -E 's/^(omf-)?((plugin|pkg|theme)-)?//;s/.git$//' command basename $name_or_url | sed -E 's/^(omf-)?((plugin|pkg|theme)-)?//;s/\\.git$//'
end end

View File

@ -0,0 +1,77 @@
function describe_omf_packages_tests
function before_all
set -gx CI WORKAROUND
end
function it_can_extract_name_from_name
set -l output (omf.packages.name foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_of_a_plugin_package
set -l output (omf.packages.name plugin-foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_of_a_theme_package
set -l output (omf.packages.name theme-foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_name_ended_in_dot_git
set -l output (omf.packages.name foo.git)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_name_with_dot
set -l output (omf.packages.name foo.bar)
assert 0 = $status
assert "foo.bar" = "$output"
end
function it_can_extract_name_from_name_ended_in_git
set -l output (omf.packages.name foobargit)
assert 0 = $status
assert "foobargit" = "$output"
end
function it_can_extract_name_from_url
set -l output (omf.packages.name http://github.com/user/foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_url_of_a_plugin_package
set -l output (omf.packages.name http://github.com/user/plugin-foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_url_of_a_theme_package
set -l output (omf.packages.name http://github.com/user/theme-foo)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_url_ended_in_dot_git
set -l output (omf.packages.name http://github.com/user/foo.git)
assert 0 = $status
assert "foo" = "$output"
end
function it_can_extract_name_from_url_with_dot
set -l output (omf.packages.name http://github.com/user/foo.bar)
assert 0 = $status
assert "foo.bar" = "$output"
end
function it_can_extract_name_from_url_ended_in_git
set -l output (omf.packages.name http://github.com/user/foobargit)
assert 0 = $status
assert "foobargit" = "$output"
end
end