Skip to content

Make tag prefix configurable by --tag-prefix option#48

Merged
Songmu merged 3 commits intoSongmu:mainfrom
KengoTODA:configurable-prefix
Feb 13, 2026
Merged

Make tag prefix configurable by --tag-prefix option#48
Songmu merged 3 commits intoSongmu:mainfrom
KengoTODA:configurable-prefix

Conversation

@KengoTODA
Copy link
Copy Markdown
Contributor

Thank you for sharing a great product with OSS community! 🤝
Here I want to ask for adding an optional commandline option to make maltmill working with release-please.

Description

This PR makes tag-prefix handling configurable via the --tag-prefix option.

  • Added --tag-prefix to both maltmill (update) and maltmill new.
  • Release selection now uses the latest release that matches the configured prefix, instead of using the repository-wide latest release.
  • Updated tests for prefix-aware selection and CLI argument parsing.
  • Updated README examples to use --tag-prefix.
  • Confirmed that this change works as expected in my local, here is the generated formlae with --tag-prefix inspequte-v option.

Why

I use release-please to handle automatic release from monorepo projects and such projects contain multiple release streams (different products/components) under different tag prefixes.
In case of inspequte, it has inspequte-vX.Y.Z stream and gradle-plugin-vX.Y.Z stream.

Without explicit prefix filtering, maltmill can pick an unrelated release/tag and update formulae incorrectly.
Making the prefix configurable ensures the intended product stream is selected.

Compatibility

  • --tag-prefix is optional.
  • Default remains v, so common vX.Y.Z repositories continue to work without changes.
  • Repositories using other prefixes should pass --tag-prefix <prefix> to avoid cross-stream release selection.

Copilot AI review requested due to automatic review settings February 11, 2026 00:49
Copy link
Copy Markdown

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

Adds a configurable --tag-prefix option so maltmill can safely operate in repos with multiple release/tag streams (e.g., monorepos managed by release-please), selecting releases only from the intended prefix.

Changes:

  • Introduces --tag-prefix for both maltmill (update) and maltmill new, and wires it through command runners.
  • Replaces repository-wide “latest release” selection with prefix-aware release discovery.
  • Adds/updates tests for tag parsing, prefix-aware selection, and CLI argument parsing; updates README example.

Reviewed changes

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

Show a summary per file
File Description
formula.go Adds tag parsing + prefix-aware latest release selection and uses it during formula updates.
cmd_maltmill.go Plumbs CLI-provided tag prefix into formula update execution.
cmd_new.go Uses prefix-aware release selection when no explicit tag is provided.
cli.go Adds --tag-prefix flag (default "v") and forwards it to subcommand parsing.
formula_test.go Adds unit tests for parsing tag names and selecting latest release by prefix.
cli_test.go Adds tests verifying -tag-prefix is parsed for both update and new.
README.md Updates usage example to show --tag-prefix.
Comments suppressed due to low confidence (1)

formula.go:110

  • fromTag := fo.tagPrefix + fo.version assumes the repository’s release tags are always exactly <prefix><version>. With the new default tag-prefix of "v", repositories that tag releases as plain semver (e.g. 1.2.3) will now fail both release selection and GetReleaseByTag (it will look for v1.2.3). Consider preserving previous behavior by either (a) defaulting tag-prefix to an empty string, or (b) auto-detecting/falling back to an empty prefix when no matching releases are found for the configured prefix.
		return false, nil
	}
	fromTag := fo.tagPrefix + fo.version
	fromRele, resp, err := ghcli.Repositories.GetReleaseByTag(ctx, fo.owner, fo.repo, fromTag)
	if err != nil {
		return false, errors.Wrapf(err, "update formula failed: %s", fo.fname)
	}
	resp.Body.Close()

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

Comment thread formula.go Outdated
Comment thread formula.go
Comment on lines +162 to +186
func findLatestReleaseByPrefix(ctx context.Context, ghcli *github.Client, owner, repo, prefix string) (*github.RepositoryRelease, *semver.Version, error) {
var (
latest *github.RepositoryRelease
latestVer *semver.Version
opt = &github.ListOptions{PerPage: 100}
)

for {
releases, resp, err := ghcli.Repositories.ListReleases(ctx, owner, repo, opt)
if resp != nil {
resp.Body.Close()
}
if err != nil {
return nil, nil, err
}
cand, candVer := selectLatestReleaseByPrefix(releases, prefix)
if cand != nil && (latest == nil || latestVer.LessThan(candVer)) {
latest = cand
latestVer = candVer
}
if resp == nil || resp.NextPage == 0 {
break
}
opt.Page = resp.NextPage
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

findLatestReleaseByPrefix paginates through all releases and performs semver comparisons, which can substantially increase GitHub API calls vs the previous GetLatestRelease (and may hit rate limits on repos with many releases). If the intended meaning of “latest” is GitHub’s ordering (newest published release), you can stop once you find the first matching non-draft/non-prerelease release while iterating pages (often within the first page). If semver-max is required, it would be good to document the extra API usage and consider adding a reasonable page limit or other mitigation.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is OK.
In most case, the target repository is under the control for who runs the maltmill. They should be able to use proper prefix that does not trigger paging so much.

Comment thread formula_test.go Outdated
Comment thread cli.go Outdated
@Songmu
Copy link
Copy Markdown
Owner

Songmu commented Feb 13, 2026

That's good. It could also support tags like lib/bar/v1.2.3, which are commonly used in Go and Terraform.

@Songmu Songmu merged commit e959847 into Songmu:main Feb 13, 2026
1 check passed
@github-actions github-actions bot mentioned this pull request Feb 13, 2026
@Songmu Songmu added the minor label Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants