fix: adress pr comments

This commit is contained in:
Shirone
2026-01-18 00:22:27 +01:00
parent 5b1e0105f4
commit 44e665f1bf
6 changed files with 48 additions and 27 deletions

View File

@@ -5,22 +5,14 @@
import * as secureFs from './secure-fs.js';
import * as path from 'path';
import type { PRState, WorktreePRInfo } from '@automaker/types';
// Re-export types for backwards compatibility
export type { PRState, WorktreePRInfo };
/** Maximum length for sanitized branch names in filesystem paths */
const MAX_SANITIZED_BRANCH_PATH_LENGTH = 200;
/** GitHub PR states as returned by the GitHub API */
export type PRState = 'OPEN' | 'MERGED' | 'CLOSED';
export interface WorktreePRInfo {
number: number;
url: string;
title: string;
/** PR state: OPEN, MERGED, or CLOSED */
state: PRState;
createdAt: string;
}
export interface WorktreeMetadata {
branch: string;
createdAt: string;

View File

@@ -13,6 +13,7 @@ import {
} from '../common.js';
import { updateWorktreePRInfo } from '../../../lib/worktree-metadata.js';
import { createLogger } from '@automaker/utils';
import { validatePRState } from '@automaker/types';
const logger = createLogger('CreatePR');
@@ -273,7 +274,7 @@ export function createCreatePRHandler() {
number: existingPr.number,
url: existingPr.url,
title: existingPr.title || title,
state: existingPr.state || 'OPEN',
state: validatePRState(existingPr.state),
createdAt: new Date().toISOString(),
});
logger.debug(
@@ -359,7 +360,7 @@ export function createCreatePRHandler() {
number: existingPr.number,
url: existingPr.url,
title: existingPr.title || title,
state: existingPr.state || 'OPEN',
state: validatePRState(existingPr.state),
createdAt: new Date().toISOString(),
});
logger.debug(`Fetched and stored existing PR: #${existingPr.number}`);

View File

@@ -18,9 +18,9 @@ import {
readAllWorktreeMetadata,
updateWorktreePRInfo,
type WorktreePRInfo,
type PRState,
} from '../../../lib/worktree-metadata.js';
import { createLogger } from '@automaker/utils';
import { validatePRState } from '@automaker/types';
import {
checkGitHubRemote,
type GitHubRemoteStatus,
@@ -221,7 +221,7 @@ async function fetchGitHubPRs(projectPath: string): Promise<Map<string, Worktree
url: pr.url,
title: pr.title,
// GitHub CLI returns state as uppercase: OPEN, MERGED, CLOSED
state: pr.state as PRState,
state: validatePRState(pr.state),
createdAt: pr.createdAt,
});
}

View File

@@ -1,14 +1,6 @@
/** GitHub PR states as returned by the GitHub API */
export type PRState = 'OPEN' | 'MERGED' | 'CLOSED';
export interface WorktreePRInfo {
number: number;
url: string;
title: string;
/** PR state: OPEN, MERGED, or CLOSED */
state: PRState;
createdAt: string;
}
// Re-export shared types from @automaker/types
export type { PRState, WorktreePRInfo } from '@automaker/types';
import type { PRState, WorktreePRInfo } from '@automaker/types';
export interface WorktreeInfo {
path: string;