Skip to content

feat: Static release bumped during dist-git generation#54

Merged
reubeno merged 5 commits intomicrosoft:mainfrom
Tonisal-byte:asalinas/bumpStaticRelease
Apr 7, 2026
Merged

feat: Static release bumped during dist-git generation#54
reubeno merged 5 commits intomicrosoft:mainfrom
Tonisal-byte:asalinas/bumpStaticRelease

Conversation

@Tonisal-byte
Copy link
Copy Markdown
Contributor

This PR allows azldev to automatically update the static release number for spec which do not use %autorelease. The new release number is calculated by taking the original release number and adding the number of synthetic commits (from the project repo). This behavior can only be observed when creating synthetic dist-git using the --with-git flag on either prepare-sources or build commands.

image

Copilot AI review requested due to automatic review settings April 1, 2026 16:51
Copy link
Copy Markdown
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

Enables automatic bumping of static RPM Release: values during synthetic dist-git generation (--with-git), so releases remain unique per synthetic commit when %autorelease is not used.

Changes:

  • Add logic to detect %autorelease vs static Release: values and bump static releases by the number of synthetic commits.
  • Invoke the static release bump as part of synthetic history preparation before staging changes.
  • Add unit tests for release detection, bumping, and Release tag extraction.

Reviewed changes

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

File Description
internal/app/azldev/core/sources/sourceprep.go Calls the new static release bump step during synthetic history creation.
internal/app/azldev/core/sources/releaseoverlay.go Introduces helpers to read Release: from spec, detect %autorelease, bump static releases, and apply an overlay.
internal/app/azldev/core/sources/releaseoverlay_test.go Adds tests covering %autorelease detection, static bumping, and Release tag parsing behavior.

Comment thread internal/app/azldev/core/sources/releaseoverlay.go Outdated
Comment thread internal/app/azldev/core/sources/release.go
Comment thread internal/app/azldev/core/sources/release.go
func BumpStaticRelease(releaseValue string, commitCount int) (string, error) {
matches := staticReleasePattern.FindStringSubmatch(releaseValue)
if matches == nil {
return "", fmt.Errorf("release value %#q does not start with an integer", releaseValue)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We know we'll find specs that don't use autorelease and don't have a standard integer followed by %{?dist}.

Example: https://src.fedoraproject.org/rpms/kernel/blob/rawhide/f/kernel.spec

For these, we'll want some way to avoid this being a fatal error. From Dan's "3 categories", this would be that 3rd case.

For those it would be okay for us to manually manage their Release values, but we'd need a way to do so. We can use an overlay to set the Release tag's value, but would then also need a way to disable this logic from running (and failing).

Copilot AI review requested due to automatic review settings April 1, 2026 21:40
Copy link
Copy Markdown
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

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

Comment thread internal/app/azldev/core/sources/release.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Copilot AI review requested due to automatic review settings April 1, 2026 22:59
@Tonisal-byte Tonisal-byte force-pushed the asalinas/bumpStaticRelease branch from e76c666 to 4cb971d Compare April 1, 2026 22:59
Copy link
Copy Markdown
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

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

Comment thread internal/app/azldev/core/sources/release.go Outdated
Comment thread internal/app/azldev/core/sources/release.go
Comment thread internal/app/azldev/core/sources/sourceprep.go
@Tonisal-byte Tonisal-byte force-pushed the asalinas/bumpStaticRelease branch from a0dd17f to c67655a Compare April 3, 2026 17:54
Copilot AI review requested due to automatic review settings April 3, 2026 17:54
Copy link
Copy Markdown
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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread internal/app/azldev/core/sources/sourceprep.go Outdated
Comment thread internal/app/azldev/core/sources/release.go Outdated
Comment thread internal/app/azldev/core/sources/release.go Outdated
Comment thread internal/app/azldev/core/sources/release.go Outdated
Comment thread internal/app/azldev/core/sources/synthistory.go Outdated
Comment thread internal/app/azldev/core/sources/release.go
Comment thread internal/app/azldev/cmds/component/diffsources.go Outdated
Comment thread internal/app/azldev/core/sources/release.go
specPath string,
commits []CommitMetadata,
) (err error) {
versionValue, err := GetSpecTagValue(p.fs, specPath, "Version")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can see us running into issues due to macros. I know there are definitely specs that define Version in terms of macros.

I'm somewhat inclined to say we should hold off on the auto-changelog-updating for now? Did you mention you were considering separating it anyway?

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.

Yeah, I went ahead and split them up in the latest iteration, should look a lot cleaner now :)

Copilot AI review requested due to automatic review settings April 7, 2026 18:36
@Tonisal-byte Tonisal-byte force-pushed the asalinas/bumpStaticRelease branch from b77ea3b to 61bfa50 Compare April 7, 2026 18:36
@Tonisal-byte Tonisal-byte force-pushed the asalinas/bumpStaticRelease branch from 61bfa50 to e1eeb8a Compare April 7, 2026 18:40
Copy link
Copy Markdown
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

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread internal/app/azldev/core/sources/sourceprep.go
Comment on lines +20 to +21
// This covers both the bare form (%autorelease) and the braced form (%{autorelease}).
var autoreleasePattern = regexp.MustCompile(`%(\{autorelease\}|autorelease($|\s))`)
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The autoreleasePattern will not match cases where %autorelease is immediately followed by another macro/text (e.g. Release: %autorelease%{?dist}), which would cause tryBumpStaticRelease to treat it as “not autorelease” and attempt a static bump. If such spec forms are supported in your RPM ecosystem, adjust the pattern to treat %autorelease as a token (e.g., using a word boundary / broader terminator than ($|\\s)).

Suggested change
// This covers both the bare form (%autorelease) and the braced form (%{autorelease}).
var autoreleasePattern = regexp.MustCompile(`%(\{autorelease\}|autorelease($|\s))`)
// This covers both the bare form (%autorelease) and the braced form (%{autorelease}),
// including cases where the bare form is immediately followed by another macro/text
// token boundary (for example, "%autorelease%{?dist}").
var autoreleasePattern = regexp.MustCompile(`%(\{autorelease\}|autorelease\b)`)

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +34
func TestReleaseUsesAutorelease(t *testing.T) {
for _, testCase := range []struct {
value string
expected bool
}{
{"%autorelease", true},
{"%{autorelease}", true},
{"1", false},
{"1%{?dist}", false},
{"3%{?dist}.1", false},
{"", false},
} {
t.Run(testCase.value, func(t *testing.T) {
assert.Equal(t, testCase.expected, sources.ReleaseUsesAutorelease(testCase.value))
})
}
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Two test issues here: (1) using testCase.value as the subtest name yields an empty subtest name for the \"\" case; prefer an explicit name field (like the other tests). (2) if this repo is built with Go versions prior to 1.22, the range variable capture pattern can lead to flaky tests; defensively rebind testCase := testCase inside the loop before t.Run(...).

Copilot uses AI. Check for mistakes.
@reubeno reubeno merged commit 75131e9 into microsoft:main Apr 7, 2026
15 checks passed
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.

4 participants