Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ on:

jobs:
call-workflow-from-shared-config:
permissions:
contents: write
uses: rubyatscale/shared-config/.github/workflows/cd.yml@main
secrets: inherit
3 changes: 3 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ on:
- cron: '0 0 * * *'
jobs:
call-workflow-from-shared-config:
permissions:
issues: write
pull-requests: write
uses: rubyatscale/shared-config/.github/workflows/stale.yml@main
2 changes: 2 additions & 0 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ on:
- opened
jobs:
call-workflow-from-shared-config:
permissions:
issues: write
uses: rubyatscale/shared-config/.github/workflows/triage.yml@main
2 changes: 1 addition & 1 deletion lib/code_teams/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Utils
sig { params(string: String).returns(String) }
def underscore(string)
string.gsub('::', '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/(?<=[A-Z])(?=[A-Z][a-z])/, '_')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
Expand Down
31 changes: 31 additions & 0 deletions spec/lib/code_teams/utils_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
RSpec.describe CodeTeams::Utils do
describe '.underscore' do
# These cases pin the exact behavior of the acronym-splitting step so that the
# linear-time zero-width rewrite stays equivalent to the original
# `/([A-Z]+)([A-Z][a-z])/` pattern.
{
'' => '',
'A' => 'a',
'Ab' => 'ab',
'AAb' => 'a_ab',
'AABb' => 'aa_bb',
'ABCd' => 'ab_cd',
'HTMLParser' => 'html_parser',
'ALLCAPS' => 'allcaps',
'allLower' => 'all_lower',
'aABc' => 'a_a_bc',
'ABCdEFg' => 'ab_cd_e_fg',
'A1b' => 'a1b',
'ABC1de' => 'abc1de',
'X9Yz' => 'x9_yz',
'HTTPResponse2XX' => 'http_response2_xx',
'Foo::BarBaz' => 'foo/bar_baz',
'Foo::HTMLParser::XMLNode' => 'foo/html_parser/xml_node',
'my-Team-Name' => 'my_team_name'
}.each do |input, expected|
it "converts #{input.inspect} to #{expected.inspect}" do
expect(described_class.underscore(input)).to eq(expected)
end
end
end
end