Skip to content

developer/bin/generate_cask_token: fix .sub! on non-string exception #186283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
17 changes: 9 additions & 8 deletions developer/bin/generate_cask_token
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,23 @@ class AppName
self.class.new(@string.delete("\v"))
end

def remove_interior_versions!
def remove_interior_versions
# done separately from REMOVE_TRAILING_PATS because this
# requires a substitution with a backreference
@string.sub!(/(?<=.)[.\d]+(#{self.class.after_interior_version_pat})\Z/i, '\1')
@string.sub!(/(?<=.)[\s.\d-]*\d[\s.\d-]*(#{self.class.after_interior_version_pat})\Z/i, '-\1')
app_name = @string
.sub(/(?<=.)[.\d]+(#{self.class.after_interior_version_pat})\Z/i, '\1')
.sub(/(?<=.)[\s.\d-]*\d[\s.\d-]*(#{self.class.after_interior_version_pat})\Z/i, '-\1')
self.class.new(app_name)
end

def remove_trailing_strings_and_versions
app_name = insert_vertical_tabs_for_camel_case
.insert_vertical_tabs_for_snake_case
while self.class.remove_trailing_pat.match(app_name.to_s) &&
!self.class.preserve_trailing_pat.match(app_name.to_s)
.insert_vertical_tabs_for_snake_case.to_s
while self.class.remove_trailing_pat.match(app_name) &&
!self.class.preserve_trailing_pat.match(app_name)
app_name.sub!(self.class.remove_trailing_pat, "")
end
app_name.remove_interior_versions!
app_name.clean_up_vertical_tabs
self.class.new(app_name).remove_interior_versions.clean_up_vertical_tabs
end

def simplified
Expand Down
Loading