@snapcommit/cli 3.9.8 → 3.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -679,10 +679,77 @@ async function executeGitCommands(commands) {
|
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
catch (error) {
|
|
682
|
+
// Capture both message and stderr for comprehensive error checking
|
|
683
|
+
const errorMsg = (error.message?.toLowerCase() || '') + ' ' + (error.stderr?.toString().toLowerCase() || '');
|
|
684
|
+
// Special handling for merge conflicts (check for ANY merge conflict indicators OR conflicted files exist)
|
|
685
|
+
let hasConflicts = false;
|
|
686
|
+
if (cmd.includes('git merge')) {
|
|
687
|
+
// Check if there are actually conflicted files
|
|
688
|
+
try {
|
|
689
|
+
const conflictedFiles = (0, child_process_1.execSync)('git diff --name-only --diff-filter=U', { encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
690
|
+
hasConflicts = conflictedFiles.length > 0;
|
|
691
|
+
}
|
|
692
|
+
catch {
|
|
693
|
+
// If command fails, check error message
|
|
694
|
+
hasConflicts = errorMsg.includes('conflict') ||
|
|
695
|
+
errorMsg.includes('both added') ||
|
|
696
|
+
errorMsg.includes('both modified') ||
|
|
697
|
+
errorMsg.includes('unmerged paths') ||
|
|
698
|
+
errorMsg.includes('automatic merge failed');
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (hasConflicts) {
|
|
702
|
+
console.log(chalk_1.default.yellow('\n⚠️ Merge conflicts detected!\n'));
|
|
703
|
+
// Try AI auto-resolution first
|
|
704
|
+
console.log(chalk_1.default.blue('🤖 Attempting AI conflict resolution...\n'));
|
|
705
|
+
const resolved = await tryAdvancedConflictResolution();
|
|
706
|
+
if (resolved) {
|
|
707
|
+
console.log(chalk_1.default.green('✓ Conflicts resolved automatically!\n'));
|
|
708
|
+
// Complete the merge
|
|
709
|
+
try {
|
|
710
|
+
(0, child_process_1.execSync)('git add -A', { encoding: 'utf-8', stdio: 'pipe' });
|
|
711
|
+
(0, child_process_1.execSync)('git commit --no-edit', { encoding: 'utf-8', stdio: 'pipe' });
|
|
712
|
+
console.log(chalk_1.default.green('✓ Merge completed\n'));
|
|
713
|
+
}
|
|
714
|
+
catch {
|
|
715
|
+
console.log(chalk_1.default.red('\n❌ Failed to complete merge after resolution\n'));
|
|
716
|
+
}
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
// AI couldn't resolve - show manual instructions
|
|
720
|
+
console.log(chalk_1.default.yellow('⚠️ AI could not auto-resolve these conflicts\n'));
|
|
721
|
+
console.log(chalk_1.default.white('Why? These conflicts require human judgment:'));
|
|
722
|
+
console.log(chalk_1.default.gray(' • Business logic decisions (which approach is correct?)'));
|
|
723
|
+
console.log(chalk_1.default.gray(' • Architectural changes (incompatible design choices)'));
|
|
724
|
+
console.log(chalk_1.default.gray(' • Semantic conflicts (both valid, but different intent)\n'));
|
|
725
|
+
console.log(chalk_1.default.white('Conflicted files:'));
|
|
726
|
+
try {
|
|
727
|
+
const conflicts = (0, child_process_1.execSync)('git diff --name-only --diff-filter=U', { encoding: 'utf-8' });
|
|
728
|
+
conflicts.split('\n').filter(f => f.trim()).forEach(file => {
|
|
729
|
+
console.log(chalk_1.default.red(` ✗ ${file}`));
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
catch {
|
|
733
|
+
console.log(chalk_1.default.gray(' (could not list files)\n'));
|
|
734
|
+
}
|
|
735
|
+
console.log(chalk_1.default.cyan('\n📖 How to resolve manually:\n'));
|
|
736
|
+
console.log(chalk_1.default.white(' 1. Open each file above in your editor'));
|
|
737
|
+
console.log(chalk_1.default.gray(' Look for conflict markers: ') + chalk_1.default.yellow('<<<<<<< HEAD'));
|
|
738
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.yellow('======='));
|
|
739
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.yellow('>>>>>>> branch'));
|
|
740
|
+
console.log('');
|
|
741
|
+
console.log(chalk_1.default.white(' 2. Choose which code to keep (or merge both)'));
|
|
742
|
+
console.log(chalk_1.default.gray(' Remove the conflict markers when done'));
|
|
743
|
+
console.log('');
|
|
744
|
+
console.log(chalk_1.default.white(' 3. After fixing, in snap type:'));
|
|
745
|
+
console.log(chalk_1.default.cyan(' complete the merge\n'));
|
|
746
|
+
console.log(chalk_1.default.gray('💡 Tip: Most conflicts are simple! Just pick the better code.\n'));
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
682
749
|
// Try to auto-fix common errors
|
|
683
750
|
const fixed = await tryAutoFix(error, cmd);
|
|
684
751
|
if (!fixed) {
|
|
685
|
-
console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
|
|
752
|
+
console.log(chalk_1.default.red(`\n❌ Command failed: ${error.message}\n`));
|
|
686
753
|
return;
|
|
687
754
|
}
|
|
688
755
|
}
|