Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Jul 11, 2024
1 parent 46d609a commit f7e77f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/bundle_update_interactive/changelog_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

GITHUB_PATTERN = %r{^(?:https?://)?github\.com/([^/]+/[^/]+)(?:\.git)?/?}
URI_KEYS = %w[source_code_uri homepage_uri bug_tracker_uri wiki_uri].freeze
FILE_PATTERN = /(?:changelog|changes|history|news|release)/
EXT_PATTERN = /(?:md|txt|rdoc)/

module BundleUpdateInteractive
class ChangelogLocator
def find_changelog_uri(name:, version: nil)
# TODO: refactor
def find_changelog_uri(name:, version: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
if version
response = Faraday.get("https://rubygems.org/api/v2/rubygems/#{name}/versions/#{version}.json")
version = nil unless response.success?
Expand All @@ -30,7 +33,7 @@ def find_changelog_uri(name:, version: nil)
github_repo = file_list.headers["Location"][GITHUB_PATTERN, 1]
file_list = Faraday.get(file_list.headers["Location"])
end
match = file_list.body.match(%r{/(#{github_repo}/blob/[^/]+/(?:changelog|changes|history|news|release)(?:\.(?:md|txt|rdoc))?)"}i)
match = file_list.body.match(%r{/(#{github_repo}/blob/[^/]+/#{FILE_PATTERN}(?:\.#{EXT_PATTERN})?)"}i)
changelog_uri = "https://github.com/#{match[1]}" if match
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundle_update_interactive/cli/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def formatted_current_version
end

def formatted_updated_version
version = semver_change.format(&method(:apply_semver_highlight))
version = semver_change.format { |part| apply_semver_highlight(part) }
git_version = apply_semver_highlight(updated_git_version)

[version, git_version].compact.join(" ")
Expand Down
3 changes: 2 additions & 1 deletion lib/bundle_update_interactive/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

module BundleUpdateInteractive
class Lockfile
def self.parse(lockfile_contents=File.read("Gemfile.lock"))
# TODO: refactor
def self.parse(lockfile_contents=File.read("Gemfile.lock")) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
parser = Bundler::LockfileParser.new(lockfile_contents)
specs_by_name = {}
exact = Set.new
Expand Down
3 changes: 2 additions & 1 deletion lib/bundle_update_interactive/outdated_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def git_version_changed?
def github_repo
return nil unless updated_git_version

updated_lockfile_entry.git_source_uri.to_s[%r{^(?:git@github.com:|https://github.com/)([^/]+/[^/]+?)(:?\.git)?(?:$|/)}i, 1]
updated_lockfile_entry.git_source_uri.to_s[%r{^(?:git@github.com:|https://github.com/)([^/]+/[^/]+?)(:?\.git)?(?:$|/)}i,
1]
end
end
end

0 comments on commit f7e77f8

Please sign in to comment.