(findings)
| 14936 | addConsoleMessage('Local merge conflicts detected - the update will clear them and save your edits to a git stash.', 'warning'); |
| 14937 | } else if (gitStatus.is_dirty) { |
| 14938 | addConsoleMessage(`${modifiedCount} local change${modifiedCount === 1 ? '' : 's'} detected - they will be saved and replayed after the update.`, 'info'); |
| 14939 | } |
| 14940 | } else if (gitStatus.has_conflicts && updateBtn) { |
| 14941 | // Nothing to pull, but the tree is in a bad state - offer the repair. |
| 14942 | updateBtn.disabled = false; |
| 14943 | updateBtn.onclick = resolveGitConflicts; |
| 14944 | updateBtn.className = 'w-full bg-red-600 hover:bg-red-700 text-white py-2 px-4 rounded transition-colors'; |
| 14945 | updateElement('update-btn-text', 'Repair Git State'); |
| 14946 | updateElement('update-status', 'Local Conflict'); |
| 14947 | if (updateStatusEl) { |
| 14948 | updateStatusEl.className = 'text-sm px-2 py-1 rounded bg-red-700 text-red-200'; |
| 14949 | } |
| 14950 | } |
| 14951 | |
| 14952 | } catch (error) { |
| 14953 | console.error('Error checking for updates:', error); |
| 14954 | updateElement('update-status', 'Error'); |
| 14955 | const statusEl = document.getElementById('update-status'); |
| 14956 | if (statusEl) { |
| 14957 | statusEl.className = 'text-sm px-2 py-1 rounded bg-red-700 text-red-300'; |
| 14958 | } |
| 14959 | updateElement('update-info', 'Failed to check for updates'); |
| 14960 | addConsoleMessage(`Failed to check for updates: ${error.message}`, 'error'); |
| 14961 | // The check endpoint answers even when git is unhappy, so a thrown error |
| 14962 | // means the web app itself is unreachable - retrying is all we can do. |
| 14963 | const updateBtn = document.getElementById('update-btn'); |
| 14964 | if (updateBtn) { |
| 14965 | updateBtn.disabled = false; |
| 14966 | updateBtn.onclick = checkForUpdates; |
| 14967 | updateBtn.className = 'w-full bg-gray-600 hover:bg-gray-500 text-white py-2 px-4 rounded transition-colors'; |
| 14968 | updateElement('update-btn-text', 'Retry Check'); |
| 14969 | } |
| 14970 | } |
| 14971 | } |
| 14972 | |
| 14973 | async function fixGitConfig() { |
| 14974 | try { |
| 14975 | updateElement('update-btn-text', 'Fixing...'); |
| 14976 | const updateBtn = document.getElementById('update-btn'); |
| 14977 | updateBtn.disabled = true; |
| 14978 | |
| 14979 | addConsoleMessage('Fixing git configuration...', 'info'); |
| 14980 | |
| 14981 | const result = await postAPI('/api/system/fix-git', {}); |
| 14982 | |
| 14983 | if (result.success) { |
| 14984 | addConsoleMessage('Git configuration fixed successfully', 'success'); |
| 14985 | updateBtn.onclick = performUpdate; |
| 14986 | updateElement('update-btn-text', 'Update System'); |
| 14987 | setTimeout(() => { |
| 14988 | checkForUpdates(); |
| 14989 | }, 1000); |
| 14990 | } else { |
| 14991 | reportUpdateProblem('Failed to fix git configuration', result); |
| 14992 | updateBtn.disabled = false; |
nothing calls this directly
no test coverage detected