Skip to content

Impl HasCooldownPassed#4

Merged
sue445 merged 2 commits into
mainfrom
feature/HasCooldownPassed
Apr 11, 2026
Merged

Impl HasCooldownPassed#4
sue445 merged 2 commits into
mainfrom
feature/HasCooldownPassed

Conversation

@sue445

@sue445 sue445 commented Apr 11, 2026

Copy link
Copy Markdown
Owner

No description provided.

@sue445 sue445 force-pushed the feature/HasCooldownPassed branch from 7374159 to 5da139d Compare April 11, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a new client helper to determine whether a specific GitHub release tag is “old enough” relative to a configured cooldown period, likely to support workflows that need to gate actions until a release has aged past a threshold.

Changes:

  • Add Client.HasCooldownPassed(...) which fetches a release by tag and compares published_at against the cooldown duration.
  • Add unit tests for the new method using httpmock.
  • Add a new JSON fixture for the GitHub “get release by tag” API response.

Reviewed changes

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

File Description
client.go Adds HasCooldownPassed method using GetReleaseByTag and cooldown comparison logic.
client_test.go Adds table-driven tests for HasCooldownPassed using a new fixture.
testdata/terraform-tags-v1.14.8.json Adds fixture JSON for GET /releases/tags/{tag} response.

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

Comment thread client.go
Comment on lines +119 to +123
ts := release.GetPublishedAt()

if ts.IsZero() {
return false, nil
}

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

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

HasCooldownPassed considers only published_at, but unlike GetLatestTagName it does not exclude draft/prerelease releases. This can return true for a prerelease tag even though the rest of the client treats prereleases as ineligible. Consider returning false when release.GetDraft() or release.GetPrerelease() is true to keep behavior consistent.

Copilot uses AI. Check for mistakes.
Comment thread client_test.go
Comment thread client_test.go
Comment on lines +89 to +95
httpmock.RegisterResponder(
"GET",
"https://api.github.com/repos/hashicorp/terraform/releases/tags/v1.14.8",
httpmock.NewStringResponder(200, readTestData("testdata/terraform-tags-v1.14.8.json")),
)

type args struct {

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

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

HasCooldownPassed supports GitHub Enterprise via ClientParams.BaseURL, but the new test only mocks api.github.com and never exercises the baseURL path (even though args.baseURL exists). Add a test case similar to TestClient_GetLatestTagName that sets baseURL and registers the corresponding responder URL.

Copilot uses AI. Check for mistakes.
Comment thread client.go
Comment on lines +119 to +123
ts := release.GetPublishedAt()

if ts.IsZero() {
return false, nil
}

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

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

The ts.IsZero() branch in HasCooldownPassed (when published_at is missing/zero) is new behavior but isn’t covered by tests. Consider adding a fixture/response with a null/empty published_at (or a draft release) to assert the method returns false without error.

Copilot uses AI. Check for mistakes.
@sue445 sue445 merged commit c891446 into main Apr 11, 2026
6 checks passed
@sue445 sue445 deleted the feature/HasCooldownPassed branch April 11, 2026 08:45
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