|
@@ -512,7 +512,7 @@ function showStatus(): void {
|
|
|
closeDb();
|
|
closeDb();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function updateCollections(): Promise<void> {
|
|
|
|
|
|
|
+async function updateCollections(pullFirst: boolean = false): Promise<void> {
|
|
|
const db = getDb();
|
|
const db = getDb();
|
|
|
cleanupDuplicateCollections(db);
|
|
cleanupDuplicateCollections(db);
|
|
|
|
|
|
|
@@ -534,6 +534,59 @@ async function updateCollections(): Promise<void> {
|
|
|
const col = collections[i];
|
|
const col = collections[i];
|
|
|
console.log(`${c.cyan}[${i + 1}/${collections.length}]${c.reset} ${c.bold}${col.pwd}${c.reset}`);
|
|
console.log(`${c.cyan}[${i + 1}/${collections.length}]${c.reset} ${c.bold}${col.pwd}${c.reset}`);
|
|
|
console.log(`${c.dim} Pattern: ${col.glob_pattern}${c.reset}`);
|
|
console.log(`${c.dim} Pattern: ${col.glob_pattern}${c.reset}`);
|
|
|
|
|
+
|
|
|
|
|
+ // Check if this is a git repository
|
|
|
|
|
+ const gitDir = `${col.pwd}/.git`;
|
|
|
|
|
+ let isGitRepo = false;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const stat = await Bun.file(gitDir).exists();
|
|
|
|
|
+ isGitRepo = stat;
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ // Not a git repo or can't access
|
|
|
|
|
+ isGitRepo = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (isGitRepo) {
|
|
|
|
|
+ console.log(`${c.dim} Git repository detected${c.reset}`);
|
|
|
|
|
+
|
|
|
|
|
+ // Execute git pull if requested
|
|
|
|
|
+ if (pullFirst) {
|
|
|
|
|
+ console.log(`${c.dim} Running git pull...${c.reset}`);
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await $`cd ${col.pwd} && git pull`.quiet();
|
|
|
|
|
+ if (result.exitCode === 0) {
|
|
|
|
|
+ const output = result.stdout.toString().trim();
|
|
|
|
|
+ if (output) {
|
|
|
|
|
+ // Show output but dimmed
|
|
|
|
|
+ console.log(`${c.dim} ${output.split('\n').join('\n ')}${c.reset}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const stderr = result.stderr.toString().trim();
|
|
|
|
|
+ console.log(`${c.yellow} Warning: git pull failed: ${stderr}${c.reset}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ console.log(`${c.yellow} Warning: git pull failed: ${err}${c.reset}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Show git status
|
|
|
|
|
+ try {
|
|
|
|
|
+ const statusResult = await $`cd ${col.pwd} && git status --short`.quiet();
|
|
|
|
|
+ if (statusResult.exitCode === 0) {
|
|
|
|
|
+ const statusOutput = statusResult.stdout.toString().trim();
|
|
|
|
|
+ if (statusOutput) {
|
|
|
|
|
+ console.log(`${c.dim} Git status:${c.reset}`);
|
|
|
|
|
+ console.log(`${c.dim} ${statusOutput.split('\n').join('\n ')}${c.reset}`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log(`${c.dim} Git status: clean${c.reset}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ // Silently ignore git status errors
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
await indexFiles(col.pwd, col.glob_pattern);
|
|
await indexFiles(col.pwd, col.glob_pattern);
|
|
|
console.log("");
|
|
console.log("");
|
|
|
}
|
|
}
|