Skip to content

formula_creator: detect GitHub version from latest release #20025

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 4 commits into from
Jun 20, 2025

Conversation

abitrolly
Copy link
Contributor

@abitrolly abitrolly commented May 30, 2025

  • 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 style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

For GitHut URLs, if --set-version is absent, and version is not detected from URL, then PR fetches the version from the data on latest release.

Basically, you now can run brew create with plain project URL and have the version filled automatically from the latest available.

brew create https://github.com/buildpacks/pack

So the data is collected from the two API calls:

$ curl -s https://api.github.com/repos/Homebrew/brew/releases/latest | jq
{
  "url": "https://api.github.com/repos/Homebrew/brew/releases/220927354",
  "assets_url": "https://api.github.com/repos/Homebrew/brew/releases/220927354/assets",
  "upload_url": "https://uploads.github.com/repos/Homebrew/brew/releases/220927354/assets{?name,label}",
  "html_url": "https://github.com/Homebrew/brew/releases/tag/4.5.3",
  "id": 220927354,
  "author": {
    "login": "MikeMcQuaid",
    "id": 125011,
    "node_id": "MDQ6VXNlcjEyNTAxMQ==",
    "avatar_url": "https://avatars.githubusercontent.com/u/125011?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/MikeMcQuaid",
    "html_url": "https://github.com/MikeMcQuaid",
    "followers_url": "https://api.github.com/users/MikeMcQuaid/followers",
    "following_url": "https://api.github.com/users/MikeMcQuaid/following{/other_user}",
    "gists_url": "https://api.github.com/users/MikeMcQuaid/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/MikeMcQuaid/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/MikeMcQuaid/subscriptions",
    "organizations_url": "https://api.github.com/users/MikeMcQuaid/orgs",
    "repos_url": "https://api.github.com/users/MikeMcQuaid/repos",
    "events_url": "https://api.github.com/users/MikeMcQuaid/events{/privacy}",
    "received_events_url": "https://api.github.com/users/MikeMcQuaid/received_events",
    "type": "User",
    "user_view_type": "public",
    "site_admin": false
  },
  "node_id": "RE_kwDOAyxcHc4NKxV6",
  "tag_name": "4.5.3",
  "target_commitish": "master",
  "name": "4.5.3",
  "draft": false,
  "prerelease": false,
  "created_at": "2025-05-25T04:55:46Z",
  "published_at": "2025-05-26T07:41:42Z",
  "assets": [
    {
      "url": "https://api.github.com/repos/Homebrew/brew/releases/assets/258620307",
      "id": 258620307,
      "node_id": "RA_kwDOAyxcHc4PajuT",
      "name": "Homebrew-4.5.3.pkg",
      "label": null,
      "uploader": {
        "login": "Bo98",
        "id": 1190754,
        "node_id": "MDQ6VXNlcjExOTA3NTQ=",
        "avatar_url": "https://avatars.githubusercontent.com/u/1190754?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/Bo98",
        "html_url": "https://github.com/Bo98",
        "followers_url": "https://api.github.com/users/Bo98/followers",
        "following_url": "https://api.github.com/users/Bo98/following{/other_user}",
        "gists_url": "https://api.github.com/users/Bo98/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/Bo98/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/Bo98/subscriptions",
        "organizations_url": "https://api.github.com/users/Bo98/orgs",
        "repos_url": "https://api.github.com/users/Bo98/repos",
        "events_url": "https://api.github.com/users/Bo98/events{/privacy}",
        "received_events_url": "https://api.github.com/users/Bo98/received_events",
        "type": "User",
        "user_view_type": "public",
        "site_admin": false
      },
      "content_type": "application/octet-stream",
      "state": "uploaded",
      "size": 117207576,
      "digest": null,
      "download_count": 8317,
      "created_at": "2025-05-27T19:23:09Z",
      "updated_at": "2025-05-27T19:24:22Z",
      "browser_download_url": "https://github.com/Homebrew/brew/releases/download/4.5.3/Homebrew-4.5.3.pkg"
    }
  ],
  "tarball_url": "https://api.github.com/repos/Homebrew/brew/tarball/4.5.3",
  "zipball_url": "https://api.github.com/repos/Homebrew/brew/zipball/4.5.3",
  "body": "<!-- Release notes generated using configuration in .github/release.yml at master -->\r\n\r\n## What's Changed\r\n* tap: get autobump list from `autobump.txt` file by @botantony in https://github.com/Homebrew/brew/pull/19923\r\n* Improve readability of disabled command message by @dduugg in https://github.com/Homebrew/brew/pull/19930\r\n* cask: document shell completion stanzas by @EricFromCanada in https://github.com/Homebrew/brew/pull/19929\r\n* Phase out using `cgi` library by @Bo98 in https://github.com/Homebrew/brew/pull/19938\r\n* docs/Homebrew-on-Linux: update instructions for Fedora-based distros by @xty in https://github.com/Homebrew/brew/pull/19944\r\n* Revert \"cask/artifact/abstract_uninstall: fix `trash_paths`\" by @carlocab in https://github.com/Homebrew/brew/pull/19941\r\n* Portable Ruby 3.4.4 by @p-linnane in https://github.com/Homebrew/brew/pull/19949\r\n* patches audit: bitbucket patches should use api by @Moisan in https://github.com/Homebrew/brew/pull/19880\r\n* dev-cmd/generate-*-api: simulate latest macOS by @EricFromCanada in https://github.com/Homebrew/brew/pull/19950\r\n* cmd/list: skip invalid Caskroom files by @EricFromCanada in https://github.com/Homebrew/brew/pull/19943\r\n* docs/Deprecating-Disabling-* review by @EricFromCanada in https://github.com/Homebrew/brew/pull/19958\r\n* Bitbucket: update generated urls by @samford in https://github.com/Homebrew/brew/pull/19973\r\n* cask/dsl: set `no_autobump!` automatically in some cases by @botantony in https://github.com/Homebrew/brew/pull/19910\r\n* bump-formula-pr: fix case when only `url` is provided by @bevanjkay in https://github.com/Homebrew/brew/pull/19971\r\n* utils/spdx: do case insensitive comparison. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19976\r\n* Anonymous OCI registry mirror support  by @byjrack in https://github.com/Homebrew/brew/pull/19885\r\n* docs/Cask-Cookbook review by @EricFromCanada in https://github.com/Homebrew/brew/pull/19968\r\n* docs/FAQ: fix broken link by @p-linnane in https://github.com/Homebrew/brew/pull/19982\r\n* Include annotations in tapioca updates by @dduugg in https://github.com/Homebrew/brew/pull/19985\r\n* Prohibit non-ASCII characters in URLs, nudge toward punycode by @colindean in https://github.com/Homebrew/brew/pull/19977\r\n* dev-cmd/tap-new: fix root_url warning. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19987\r\n* dev-cmd/update-maintainers: various fixes. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19986\r\n* cask/audit: skip audit_rosetta on Intel-only casks & OSes by @EricFromCanada in https://github.com/Homebrew/brew/pull/19983\r\n* Truncate long release notes in formula PR descriptions by @issyl0 in https://github.com/Homebrew/brew/pull/19989\r\n* dependabot: use more groups. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19991\r\n* bundle/commands/exec: fix exit code handling. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19993\r\n* dev-cmd/bump-formula-pr: use `Formatter.truncate`. by @MikeMcQuaid in https://github.com/Homebrew/brew/pull/19995\r\n* cask/dsl: set `no_autobump!` if livecheck uses `:extract_plist` by @botantony in https://github.com/Homebrew/brew/pull/19998\r\n* uninstall: exclude configurational filess that belong to other formulae by @botantony in https://github.com/Homebrew/brew/pull/19959\r\n* docs: localize internal URLs by @EricFromCanada in https://github.com/Homebrew/brew/pull/20000\r\n* docs/Typechecking review by @EricFromCanada in https://github.com/Homebrew/brew/pull/20001\r\n* bundle: add support for selective cleanup by @Bo98 in https://github.com/Homebrew/brew/pull/20002\r\n* feat: add clarification of macOS patches in Support-Tiers by @SMillerDev in https://github.com/Homebrew/brew/pull/20007\r\n* feat: add _ to powershell completion filename by @daeho-ro in https://github.com/Homebrew/brew/pull/20008\r\n\r\n## New Contributors\r\n* @xty made their first contribution in https://github.com/Homebrew/brew/pull/19944\r\n* @byjrack made their first contribution in https://github.com/Homebrew/brew/pull/19885\r\n\r\n**Full Changelog**: https://github.com/Homebrew/brew/compare/4.5.2...4.5.3",
  "reactions": {
    "url": "https://api.github.com/repos/Homebrew/brew/releases/220927354/reactions",
    "total_count": 22,
    "+1": 13,
    "-1": 0,
    "laugh": 0,
    "hooray": 2,
    "confused": 0,
    "heart": 4,
    "rocket": 2,
    "eyes": 1
  },
  "mentions_count": 16
}

@abitrolly abitrolly force-pushed the new-detect-latest-release branch 2 times, most recently from b363843 to 0dff1e9 Compare May 30, 2025 07:41
@abitrolly abitrolly changed the title formula_creator: deduplicate GitHub check formula_creator: refactor GitHub and version checks May 30, 2025
@abitrolly abitrolly marked this pull request as draft May 30, 2025 07:44
@abitrolly abitrolly force-pushed the new-detect-latest-release branch from 0dff1e9 to ad976c4 Compare May 30, 2025 08:15
@abitrolly abitrolly marked this pull request as ready for review May 30, 2025 08:16
@abitrolly abitrolly changed the title formula_creator: refactor GitHub and version checks formula_creator: detect GitHub version from latest release May 30, 2025
@abitrolly abitrolly force-pushed the new-detect-latest-release branch 2 times, most recently from 25f480e to 825afde Compare May 31, 2025 02:37
@abitrolly abitrolly force-pushed the new-detect-latest-release branch 2 times, most recently from f4ae3e5 to 518e29e Compare June 12, 2025 13:32
@abitrolly abitrolly marked this pull request as draft June 15, 2025 17:27
@abitrolly abitrolly force-pushed the new-detect-latest-release branch 2 times, most recently from f01a1ed to 94473af Compare June 18, 2025 09:57
@abitrolly abitrolly marked this pull request as ready for review June 18, 2025 10:04
@MikeMcQuaid
Copy link
Member

@abitrolly This needs rebased. Shout after that and I'll rereview.

@abitrolly abitrolly force-pushed the new-detect-latest-release branch 2 times, most recently from 9f6f9ff to 86c36cd Compare June 18, 2025 23:06
@abitrolly
Copy link
Contributor Author

@abitrolly This needs rebased. Shout after that and I'll rereview.

@MikeMcQuaid SHOUTING!

@MikeMcQuaid MikeMcQuaid force-pushed the new-detect-latest-release branch from 83b412e to 2cd7a32 Compare June 19, 2025 08:02
@MikeMcQuaid
Copy link
Member

@abitrolly Reviewed and improved code style. Please check it still works for you as expected and then I'll merge.

Copy link
Contributor Author

@abitrolly abitrolly left a comment

Choose a reason for hiding this comment

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

@MikeMcQuaid no, it doesn't work. Test don't fail, but version is not detected on real command.

$ brew create https://github.com/buildpacks/pack -d
==> version from url:
==> github: buildpacks pack head:false
==> name from github: pack
...
==> github: version from latest_release:
Formula name [pack]: ^C

@MikeMcQuaid
Copy link
Member

Test don't fail, but version is not detected on real command.

Please fix/add the tests so they reproduce this failure.

@abitrolly
Copy link
Contributor Author

@MikeMcQuaid it appears it was only debug message that was incorrect. Fixed that and added test for name override in GitHub URLs.

Now it works as expected.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jun 20, 2025
Merged via the queue into Homebrew:master with commit e6d4db8 Jun 20, 2025
71 of 73 checks passed
@abitrolly abitrolly deleted the new-detect-latest-release branch June 20, 2025 11:42
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.

2 participants