Skip to content

Commit bb02f2f

Browse files
revert: drop timestamp branch name warning (false positive risk)
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent fc92cd5 commit bb02f2f

3 files changed

Lines changed: 1 addition & 90 deletions

File tree

dist/index.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39329,7 +39329,6 @@ async function run() {
3932939329
if (!token) {
3933039330
throw new Error("GitHub token is required. Please provide a token with appropriate permissions.");
3933139331
}
39332-
warnIfDynamicBranchName(branch);
3933339332
if (updateFromSource) {
3933439333
await updateFromSourceSpec(token, branch, autoMerge);
3933539334
}
@@ -39520,28 +39519,6 @@ async function syncChanges(options) {
3952039519
throw new Error(`Failed to sync changes: ${error instanceof Error ? error.message : "Unknown error"}`);
3952139520
}
3952239521
}
39523-
// Warn if the branch name appears to contain a dynamic/timestamp component,
39524-
// which would prevent PR deduplication from working.
39525-
function warnIfDynamicBranchName(branch) {
39526-
// Match common timestamp patterns in branch names:
39527-
// - ISO-like dates: 2026-02-25, 2026-02-25T00-27-08
39528-
// - Unix timestamps: 1772467782 (10+ digits)
39529-
// - Date segments: 20260225, 202602
39530-
const timestampPatterns = [
39531-
/\d{4}-\d{2}-\d{2}/, // ISO date: 2026-02-25
39532-
/\d{4}-\d{2}-\d{2}T\d{2}/, // ISO datetime: 2026-02-25T00
39533-
/\d{10,}/, // Unix timestamp: 1772467782
39534-
/\d{8,}/, // Compact date: 20260225
39535-
];
39536-
for (const pattern of timestampPatterns) {
39537-
if (pattern.test(branch)) {
39538-
core.warning(`Branch name '${branch}' appears to contain a timestamp or date. ` +
39539-
`Using dynamic branch names means each run creates a new branch and a new PR. ` +
39540-
`For PR deduplication to work, use a stable branch name (e.g., 'update-api').`);
39541-
return;
39542-
}
39543-
}
39544-
}
3954539522
async function branchExists(owner, repo, branchName, octokit) {
3954639523
try {
3954739524
await octokit.rest.git.getRef({

src/sync.test.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
44
const state = {
55
infoCalls: [] as string[],
66
setFailedCalls: [] as string[],
7-
warningCalls: [] as string[],
87
execCalls: [] as [string, string[] | undefined, unknown][], // [cmd, args, opts]
98
getInputImpl: (_name: string): string => "",
109
getBooleanInputImpl: (_name: string): boolean => false,
@@ -43,9 +42,7 @@ vi.mock("@actions/core", () => ({
4342
setFailed: vi.fn((msg: string) => {
4443
state.setFailedCalls.push(msg);
4544
}),
46-
warning: vi.fn((msg: string) => {
47-
state.warningCalls.push(msg);
48-
}),
45+
warning: vi.fn(),
4946
}));
5047

5148
vi.mock("@actions/github", () => ({
@@ -88,7 +85,6 @@ function setupMocks({
8885
// Reset shared state
8986
state.infoCalls = [];
9087
state.setFailedCalls = [];
91-
state.warningCalls = [];
9288
state.execCalls = [];
9389

9490
// Setup input implementations
@@ -156,7 +152,6 @@ beforeEach(() => {
156152
vi.clearAllMocks();
157153
state.infoCalls = [];
158154
state.setFailedCalls = [];
159-
state.warningCalls = [];
160155
state.execCalls = [];
161156
});
162157

@@ -403,39 +398,6 @@ describe("updateFromSourceSpec", () => {
403398
});
404399
});
405400

406-
describe("dynamic branch name warning", () => {
407-
it("should warn when branch name contains an ISO date", async () => {
408-
setupMocks({ hasChanges: false });
409-
state.getInputImpl = (name: string): string => {
410-
const inputs: Record<string, string> = {
411-
token: "fake-token",
412-
branch: "update-openapi-spec-2026-02-25T00-27-08-474Z",
413-
auto_merge: "false",
414-
update_from_source: "true",
415-
};
416-
return inputs[name] || "";
417-
};
418-
await importAndRun();
419-
420-
expect(state.warningCalls).toEqual(
421-
expect.arrayContaining([
422-
expect.stringContaining("appears to contain a timestamp"),
423-
]),
424-
);
425-
});
426-
427-
it("should not warn for a stable branch name", async () => {
428-
setupMocks({ hasChanges: false });
429-
await importAndRun();
430-
431-
expect(state.warningCalls).not.toEqual(
432-
expect.arrayContaining([
433-
expect.stringContaining("appears to contain a timestamp"),
434-
]),
435-
);
436-
});
437-
});
438-
439401
describe("when auto_merge is true", () => {
440402
it("should not check for existing PRs or create new ones", async () => {
441403
setupMocks({ hasChanges: true, autoMerge: true });

src/sync.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export async function run(): Promise<void> {
3636
);
3737
}
3838

39-
warnIfDynamicBranchName(branch);
40-
4139
if (updateFromSource) {
4240
await updateFromSourceSpec(token, branch, autoMerge);
4341
} else {
@@ -342,32 +340,6 @@ async function syncChanges(options: SyncOptions): Promise<void> {
342340
}
343341
}
344342

345-
// Warn if the branch name appears to contain a dynamic/timestamp component,
346-
// which would prevent PR deduplication from working.
347-
function warnIfDynamicBranchName(branch: string): void {
348-
// Match common timestamp patterns in branch names:
349-
// - ISO-like dates: 2026-02-25, 2026-02-25T00-27-08
350-
// - Unix timestamps: 1772467782 (10+ digits)
351-
// - Date segments: 20260225, 202602
352-
const timestampPatterns = [
353-
/\d{4}-\d{2}-\d{2}/, // ISO date: 2026-02-25
354-
/\d{4}-\d{2}-\d{2}T\d{2}/, // ISO datetime: 2026-02-25T00
355-
/\d{10,}/, // Unix timestamp: 1772467782
356-
/\d{8,}/, // Compact date: 20260225
357-
];
358-
359-
for (const pattern of timestampPatterns) {
360-
if (pattern.test(branch)) {
361-
core.warning(
362-
`Branch name '${branch}' appears to contain a timestamp or date. ` +
363-
`Using dynamic branch names means each run creates a new branch and a new PR. ` +
364-
`For PR deduplication to work, use a stable branch name (e.g., 'update-api').`,
365-
);
366-
return;
367-
}
368-
}
369-
}
370-
371343
async function branchExists(
372344
owner: string,
373345
repo: string,

0 commit comments

Comments
 (0)