chore: apply requested changes

This commit is contained in:
Ralph Khreish
2025-10-08 21:56:32 +02:00
parent 519d8bdfcb
commit f0d1d5de89
3 changed files with 24 additions and 8 deletions

View File

@@ -184,7 +184,7 @@ export class AutopilotCommand extends Command {
padding: 1,
borderStyle: 'round',
borderColor: 'cyan',
width: process.stdout.columns * 0.95 || 100
width: process.stdout.columns ? process.stdout.columns * 0.95 : 100
}
)
);

View File

@@ -124,7 +124,8 @@ export class PreflightChecker {
// Check for changes (staged/unstaged/untracked) without requiring HEAD
const status = execSync('git status --porcelain', {
cwd: this.projectRoot,
encoding: 'utf-8'
encoding: 'utf-8',
timeout: 5000
});
if (status.trim().length > 0) {
return {
@@ -266,7 +267,8 @@ export class PreflightChecker {
const version = execSync(`${command} ${versionArgs.join(' ')}`, {
cwd: this.projectRoot,
encoding: 'utf-8',
stdio: 'pipe'
stdio: 'pipe',
timeout: 5000
})
.trim()
.split('\n')[0];
@@ -294,7 +296,8 @@ export class PreflightChecker {
const version = execSync('gh --version', {
cwd: this.projectRoot,
encoding: 'utf-8',
stdio: 'pipe'
stdio: 'pipe',
timeout: 5000
})
.trim()
.split('\n')[0];

View File

@@ -129,11 +129,12 @@ export async function getRemoteBranches(
'git branch -r --format="%(refname:short)"',
{ cwd: projectRoot, maxBuffer: 10 * 1024 * 1024 }
);
return stdout
const names = stdout
.trim()
.split('\n')
.filter((branch) => branch.length > 0 && !branch.includes('HEAD'))
.map((branch) => branch.replace(/^[^/]+\//, '').trim());
return Array.from(new Set(names));
} catch (error) {
return [];
}
@@ -220,7 +221,8 @@ export async function getDefaultBranch(
// Parse `git remote show` (preferred)
try {
const { stdout } = await execAsync(`git remote show ${primary}`, {
cwd: projectRoot
cwd: projectRoot,
maxBuffer: 10 * 1024 * 1024
});
const m = stdout.match(/HEAD branch:\s+([^\s]+)/);
if (m) return m[1].trim();
@@ -264,8 +266,10 @@ export async function isOnDefaultBranch(projectRoot: string): Promise<boolean> {
}
try {
const currentBranch = await getCurrentBranch(projectRoot);
const defaultBranch = await getDefaultBranch(projectRoot);
const [currentBranch, defaultBranch] = await Promise.all([
getCurrentBranch(projectRoot),
getDefaultBranch(projectRoot)
]);
return (
currentBranch !== null &&
defaultBranch !== null &&
@@ -357,6 +361,15 @@ export async function getWorktrees(
for (const line of lines) {
if (line.startsWith('worktree ')) {
// flush previous entry if present
if (current.path) {
worktrees.push({
path: current.path,
branch: current.branch || null,
head: current.head || ''
});
current = {};
}
current.path = line.substring(9);
} else if (line.startsWith('HEAD ')) {
current.head = line.substring(5);