Skip to content

Conversation

@samford
Copy link
Member

@samford samford commented Jan 29, 2026

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

This refactors some of the livecheck Git strategy's methods to separate concerns and improve test coverage. Namely, this:

  • Renames #tag_info to #ls_remote_tags and simplifies it to only return the stdout and/or stderr content in a hash.
  • Creates a new #tags_from_content method that contains some simple code to parse tags from git ls-remote --tags output using the TAG_REGEX. This code could be inlined but it may be useful to offer this as a method, in case it's ever needed outside the strategy (e.g., a strategy block).

This also adds a provided_content parameter to Git#find_versions, to bring it in line with other strategies. I will be doing this for the rest of the strategies (and renaming the parameter to content) in an upcoming PR but I've isolated the changes for Git because they're more involved.

Along with the above changes, the expanded tests bring the Git strategy to 100% coverage for lines and branches, which is the actual goal here. The content parameter will eventually be used to add caching to livecheck for URLs that are fetched more than once in a given run and this is part of the foundation for that.

Copilot AI review requested due to automatic review settings January 29, 2026 16:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Git livecheck strategy to improve code organization, test coverage, and consistency with other strategies. The refactoring separates concerns by creating dedicated methods for parsing tags and extracting versions from content, and adds support for cached content via a provided_content parameter.

Changes:

  • Renamed tag_info to ls_remote_tags and simplified it to only return stdout/stderr content
  • Created new tags_from_content method to parse tags from git ls-remote output
  • Renamed versions_from_tags to versions_from_content and refactored it to work with raw content instead of pre-parsed tags
  • Added provided_content parameter to find_versions to support content caching
  • Expanded test coverage to 100% for lines and branches
  • Improved preprocess_url logic by changing path.nil? check to path.blank? for better edge case handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
Library/Homebrew/livecheck/strategy/git.rb Refactored Git strategy methods to separate concerns, added TAG_REGEX constant, improved error handling, and aligned with Strategic interface
Library/Homebrew/test/livecheck/strategy/git_spec.rb Expanded test suite with comprehensive coverage for all methods, edge cases, and error conditions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@samford samford force-pushed the livecheck/refactor-git-strategy-expand-tests branch from 2237e09 to e800ad1 Compare January 29, 2026 17:39
@samford
Copy link
Member Author

samford commented Jan 29, 2026

The latest push includes test changes that address Copilot feedback:

  • Removed duplicate preprocess_url test cases
  • Incorpoated the existing ls_remote_tags test [that makes a network request] into the main ::ls_remote_tags describe block with the other tests
  • Added an ls_remote_tags test to check the return hash when both stdout and stderr are present (it should contain both content and messages)
  • Added a find_versions test to check behavior when the ls_remote_tags hash contains a messages value (the messages value should be merged into match_data)

This refactors some of the livecheck `Git` strategy's methods to
separate concerns and improve test coverage. Namely, this:

* Renames `#tag_info` to `#ls_remote_tags` and simplifies it to only
return the `stdout` and/or `stderr` content in a hash.
* Creates a new `#tags_from_content` method that contains some simple
code to parse tags from `git ls-remote --tags` output using the
`TAG_REGEX`. This code could be inlined but it may be useful to offer
this as a method, in case it's ever needed outside the strategy (e.g.,
a `strategy` block).

This also adds a `provided_content` parameter to `Git#find_versions`,
to bring it in line with other strategies. I will be doing this for
the rest of the strategies (and renaming the parameter to `content`)
in an upcoming PR but I've isolated the changes for `Git` because
they're more involved.

Along with the above changes, the expanded tests bring the `Git`
strategy to 100% coverage for lines and branches.
@samford samford force-pushed the livecheck/refactor-git-strategy-expand-tests branch from e800ad1 to de1f553 Compare January 29, 2026 18:14
@samford samford mentioned this pull request Jan 29, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants