chore: apply requested changes
This commit is contained in:
@@ -184,7 +184,7 @@ export class AutopilotCommand extends Command {
|
|||||||
padding: 1,
|
padding: 1,
|
||||||
borderStyle: 'round',
|
borderStyle: 'round',
|
||||||
borderColor: 'cyan',
|
borderColor: 'cyan',
|
||||||
width: process.stdout.columns * 0.95 || 100
|
width: process.stdout.columns ? process.stdout.columns * 0.95 : 100
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ export class PreflightChecker {
|
|||||||
// Check for changes (staged/unstaged/untracked) without requiring HEAD
|
// Check for changes (staged/unstaged/untracked) without requiring HEAD
|
||||||
const status = execSync('git status --porcelain', {
|
const status = execSync('git status --porcelain', {
|
||||||
cwd: this.projectRoot,
|
cwd: this.projectRoot,
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8',
|
||||||
|
timeout: 5000
|
||||||
});
|
});
|
||||||
if (status.trim().length > 0) {
|
if (status.trim().length > 0) {
|
||||||
return {
|
return {
|
||||||
@@ -266,7 +267,8 @@ export class PreflightChecker {
|
|||||||
const version = execSync(`${command} ${versionArgs.join(' ')}`, {
|
const version = execSync(`${command} ${versionArgs.join(' ')}`, {
|
||||||
cwd: this.projectRoot,
|
cwd: this.projectRoot,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
stdio: 'pipe'
|
stdio: 'pipe',
|
||||||
|
timeout: 5000
|
||||||
})
|
})
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')[0];
|
.split('\n')[0];
|
||||||
@@ -294,7 +296,8 @@ export class PreflightChecker {
|
|||||||
const version = execSync('gh --version', {
|
const version = execSync('gh --version', {
|
||||||
cwd: this.projectRoot,
|
cwd: this.projectRoot,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
stdio: 'pipe'
|
stdio: 'pipe',
|
||||||
|
timeout: 5000
|
||||||
})
|
})
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')[0];
|
.split('\n')[0];
|
||||||
|
|||||||
@@ -129,11 +129,12 @@ export async function getRemoteBranches(
|
|||||||
'git branch -r --format="%(refname:short)"',
|
'git branch -r --format="%(refname:short)"',
|
||||||
{ cwd: projectRoot, maxBuffer: 10 * 1024 * 1024 }
|
{ cwd: projectRoot, maxBuffer: 10 * 1024 * 1024 }
|
||||||
);
|
);
|
||||||
return stdout
|
const names = stdout
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((branch) => branch.length > 0 && !branch.includes('HEAD'))
|
.filter((branch) => branch.length > 0 && !branch.includes('HEAD'))
|
||||||
.map((branch) => branch.replace(/^[^/]+\//, '').trim());
|
.map((branch) => branch.replace(/^[^/]+\//, '').trim());
|
||||||
|
return Array.from(new Set(names));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -220,7 +221,8 @@ export async function getDefaultBranch(
|
|||||||
// Parse `git remote show` (preferred)
|
// Parse `git remote show` (preferred)
|
||||||
try {
|
try {
|
||||||
const { stdout } = await execAsync(`git remote show ${primary}`, {
|
const { stdout } = await execAsync(`git remote show ${primary}`, {
|
||||||
cwd: projectRoot
|
cwd: projectRoot,
|
||||||
|
maxBuffer: 10 * 1024 * 1024
|
||||||
});
|
});
|
||||||
const m = stdout.match(/HEAD branch:\s+([^\s]+)/);
|
const m = stdout.match(/HEAD branch:\s+([^\s]+)/);
|
||||||
if (m) return m[1].trim();
|
if (m) return m[1].trim();
|
||||||
@@ -264,8 +266,10 @@ export async function isOnDefaultBranch(projectRoot: string): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const currentBranch = await getCurrentBranch(projectRoot);
|
const [currentBranch, defaultBranch] = await Promise.all([
|
||||||
const defaultBranch = await getDefaultBranch(projectRoot);
|
getCurrentBranch(projectRoot),
|
||||||
|
getDefaultBranch(projectRoot)
|
||||||
|
]);
|
||||||
return (
|
return (
|
||||||
currentBranch !== null &&
|
currentBranch !== null &&
|
||||||
defaultBranch !== null &&
|
defaultBranch !== null &&
|
||||||
@@ -357,6 +361,15 @@ export async function getWorktrees(
|
|||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.startsWith('worktree ')) {
|
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);
|
current.path = line.substring(9);
|
||||||
} else if (line.startsWith('HEAD ')) {
|
} else if (line.startsWith('HEAD ')) {
|
||||||
current.head = line.substring(5);
|
current.head = line.substring(5);
|
||||||
|
|||||||
Reference in New Issue
Block a user