| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 1 | // mock-git-data-service.ts |
| 2 | // Mock implementation of GitDataService for the demo environment |
| 3 | |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 4 | import { GitDataService, GitDiffFile } from "../git-data-service"; |
| 5 | import { GitLogEntry } from "../../types"; |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 6 | |
| 7 | /** |
| 8 | * Demo implementation of GitDataService with canned responses |
| 9 | */ |
| 10 | export class MockGitDataService implements GitDataService { |
| 11 | constructor() { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 12 | console.log("MockGitDataService instance created"); |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | // Mock commit history |
| 16 | private mockCommits: GitLogEntry[] = [ |
| 17 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 18 | hash: "abc123456789", |
| 19 | subject: "Implement new file picker UI", |
| 20 | refs: ["HEAD", "main"], |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 21 | }, |
| 22 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 23 | hash: "def987654321", |
| 24 | subject: "Add range picker component", |
| 25 | refs: [], |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 26 | }, |
| 27 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 28 | hash: "ghi456789123", |
| 29 | subject: "Fix styling issues in navigation", |
| 30 | refs: [], |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 31 | }, |
| 32 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 33 | hash: "jkl789123456", |
| 34 | subject: "Initial commit", |
| 35 | refs: ["sketch-base"], |
| 36 | }, |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 37 | ]; |
| 38 | |
| 39 | // Mock diff files for various scenarios |
| 40 | private mockDiffFiles: GitDiffFile[] = [ |
| 41 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 42 | path: "src/components/FilePicker.js", |
| Josh Bleecher Snyder | bcc1c41 | 2025-05-29 00:36:49 +0000 | [diff] [blame] | 43 | old_path: "", |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 44 | status: "A", |
| 45 | new_mode: "100644", |
| 46 | old_mode: "000000", |
| 47 | old_hash: "0000000000000000000000000000000000000000", |
| 48 | new_hash: "def0123456789abcdef0123456789abcdef0123", |
| Philip Zeyliger | e89b308 | 2025-05-29 03:16:06 +0000 | [diff] [blame] | 49 | additions: 54, |
| 50 | deletions: 0, |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 51 | }, |
| 52 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 53 | path: "src/components/RangePicker.js", |
| Josh Bleecher Snyder | bcc1c41 | 2025-05-29 00:36:49 +0000 | [diff] [blame] | 54 | old_path: "", |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 55 | status: "A", |
| 56 | new_mode: "100644", |
| 57 | old_mode: "000000", |
| 58 | old_hash: "0000000000000000000000000000000000000000", |
| 59 | new_hash: "cde0123456789abcdef0123456789abcdef0123", |
| Philip Zeyliger | e89b308 | 2025-05-29 03:16:06 +0000 | [diff] [blame] | 60 | additions: 32, |
| 61 | deletions: 0, |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 62 | }, |
| 63 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 64 | path: "src/components/App.js", |
| Josh Bleecher Snyder | bcc1c41 | 2025-05-29 00:36:49 +0000 | [diff] [blame] | 65 | old_path: "", |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 66 | status: "M", |
| 67 | new_mode: "100644", |
| 68 | old_mode: "100644", |
| 69 | old_hash: "abc0123456789abcdef0123456789abcdef0123", |
| 70 | new_hash: "bcd0123456789abcdef0123456789abcdef0123", |
| Philip Zeyliger | e89b308 | 2025-05-29 03:16:06 +0000 | [diff] [blame] | 71 | additions: 15, |
| 72 | deletions: 3, |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 73 | }, |
| 74 | { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 75 | path: "src/styles/main.css", |
| Josh Bleecher Snyder | bcc1c41 | 2025-05-29 00:36:49 +0000 | [diff] [blame] | 76 | old_path: "", |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 77 | status: "M", |
| 78 | new_mode: "100644", |
| 79 | old_mode: "100644", |
| 80 | old_hash: "fgh0123456789abcdef0123456789abcdef0123", |
| 81 | new_hash: "ghi0123456789abcdef0123456789abcdef0123", |
| Philip Zeyliger | e89b308 | 2025-05-29 03:16:06 +0000 | [diff] [blame] | 82 | additions: 25, |
| 83 | deletions: 8, |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 84 | }, |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 85 | ]; |
| 86 | |
| 87 | // Mock file content for different files and commits |
| 88 | private appJSOriginal = `function App() { |
| 89 | return ( |
| 90 | <div className="app"> |
| 91 | <header> |
| 92 | <h1>Git Diff Viewer</h1> |
| 93 | </header> |
| 94 | <main> |
| 95 | <p>Select a file to view differences</p> |
| 96 | </main> |
| 97 | </div> |
| 98 | ); |
| 99 | }`; |
| 100 | |
| 101 | private appJSModified = `function App() { |
| 102 | const [files, setFiles] = useState([]); |
| 103 | const [selectedFile, setSelectedFile] = useState(null); |
| 104 | |
| 105 | // Load commits and files |
| 106 | useEffect(() => { |
| 107 | // Code to load commits would go here |
| 108 | // setCommits(...); |
| 109 | }, []); |
| 110 | |
| 111 | return ( |
| 112 | <div className="app"> |
| 113 | <header> |
| 114 | <h1>Git Diff Viewer</h1> |
| 115 | </header> |
| 116 | <main> |
| 117 | <FilePicker files={files} onFileSelect={setSelectedFile} /> |
| 118 | <div className="diff-view"> |
| 119 | {selectedFile ? ( |
| 120 | <div>Diff view for {selectedFile.path}</div> |
| 121 | ) : ( |
| 122 | <p>Select a file to view differences</p> |
| 123 | )} |
| 124 | </div> |
| 125 | </main> |
| 126 | </div> |
| 127 | ); |
| 128 | }`; |
| 129 | |
| 130 | private filePickerJS = `function FilePicker({ files, onFileSelect }) { |
| 131 | const [selectedIndex, setSelectedIndex] = useState(0); |
| 132 | |
| 133 | useEffect(() => { |
| 134 | // Reset selection when files change |
| 135 | setSelectedIndex(0); |
| 136 | if (files.length > 0) { |
| 137 | onFileSelect(files[0]); |
| 138 | } |
| 139 | }, [files, onFileSelect]); |
| 140 | |
| 141 | const handleNext = () => { |
| 142 | if (selectedIndex < files.length - 1) { |
| 143 | const newIndex = selectedIndex + 1; |
| 144 | setSelectedIndex(newIndex); |
| 145 | onFileSelect(files[newIndex]); |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | const handlePrevious = () => { |
| 150 | if (selectedIndex > 0) { |
| 151 | const newIndex = selectedIndex - 1; |
| 152 | setSelectedIndex(newIndex); |
| 153 | onFileSelect(files[newIndex]); |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | return ( |
| 158 | <div className="file-picker"> |
| 159 | <select value={selectedIndex} onChange={(e) => { |
| 160 | const index = parseInt(e.target.value, 10); |
| 161 | setSelectedIndex(index); |
| 162 | onFileSelect(files[index]); |
| 163 | }}> |
| 164 | {files.map((file, index) => ( |
| 165 | <option key={file.path} value={index}> |
| 166 | {file.status} {file.path} |
| 167 | </option> |
| 168 | ))} |
| 169 | </select> |
| 170 | |
| 171 | <div className="navigation-buttons"> |
| 172 | <button |
| 173 | onClick={handlePrevious} |
| 174 | disabled={selectedIndex === 0} |
| 175 | > |
| 176 | Previous |
| 177 | </button> |
| 178 | <button |
| 179 | onClick={handleNext} |
| 180 | disabled={selectedIndex === files.length - 1} |
| 181 | > |
| 182 | Next |
| 183 | </button> |
| 184 | </div> |
| 185 | </div> |
| 186 | ); |
| 187 | }`; |
| 188 | |
| 189 | private rangePickerJS = `function RangePicker({ commits, onRangeChange }) { |
| 190 | const [rangeType, setRangeType] = useState('range'); |
| 191 | const [startCommit, setStartCommit] = useState(commits[0]); |
| 192 | const [endCommit, setEndCommit] = useState(commits[commits.length - 1]); |
| 193 | |
| 194 | const handleTypeChange = (e) => { |
| 195 | setRangeType(e.target.value); |
| 196 | if (e.target.value === 'single') { |
| 197 | onRangeChange({ type: 'single', commit: startCommit }); |
| 198 | } else { |
| 199 | onRangeChange({ type: 'range', from: startCommit, to: endCommit }); |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | return ( |
| 204 | <div className="range-picker"> |
| 205 | <div className="range-type-selector"> |
| 206 | <label> |
| 207 | <input |
| 208 | type="radio" |
| 209 | value="range" |
| 210 | checked={rangeType === 'range'} |
| 211 | onChange={handleTypeChange} |
| 212 | /> |
| 213 | Commit Range |
| 214 | </label> |
| 215 | <label> |
| 216 | <input |
| 217 | type="radio" |
| 218 | value="single" |
| 219 | checked={rangeType === 'single'} |
| 220 | onChange={handleTypeChange} |
| 221 | /> |
| 222 | Single Commit |
| 223 | </label> |
| 224 | </div> |
| 225 | </div> |
| 226 | ); |
| 227 | }`; |
| 228 | |
| 229 | private mainCSSOriginal = `body { |
| 230 | font-family: sans-serif; |
| 231 | margin: 0; |
| 232 | padding: 0; |
| 233 | } |
| 234 | |
| 235 | .app { |
| 236 | max-width: 1200px; |
| 237 | margin: 0 auto; |
| 238 | padding: 20px; |
| 239 | } |
| 240 | |
| 241 | header { |
| 242 | margin-bottom: 20px; |
| 243 | } |
| 244 | |
| 245 | h1 { |
| 246 | color: #333; |
| 247 | }`; |
| 248 | |
| 249 | private mainCSSModified = `body { |
| 250 | font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
| 251 | margin: 0; |
| 252 | padding: 0; |
| 253 | background-color: #f5f5f5; |
| 254 | } |
| 255 | |
| 256 | .app { |
| 257 | max-width: 1200px; |
| 258 | margin: 0 auto; |
| 259 | padding: 20px; |
| 260 | } |
| 261 | |
| 262 | header { |
| 263 | margin-bottom: 20px; |
| 264 | border-bottom: 1px solid #ddd; |
| 265 | padding-bottom: 10px; |
| 266 | } |
| 267 | |
| 268 | h1 { |
| 269 | color: #333; |
| 270 | } |
| 271 | |
| 272 | .file-picker { |
| 273 | display: flex; |
| 274 | gap: 8px; |
| 275 | align-items: center; |
| 276 | margin-bottom: 20px; |
| 277 | } |
| 278 | |
| 279 | .file-picker select { |
| 280 | flex: 1; |
| 281 | padding: 8px; |
| 282 | border-radius: 4px; |
| 283 | border: 1px solid #ddd; |
| 284 | } |
| 285 | |
| 286 | .navigation-buttons { |
| 287 | display: flex; |
| 288 | gap: 8px; |
| 289 | } |
| 290 | |
| 291 | button { |
| 292 | padding: 8px 12px; |
| 293 | background-color: #4a7dfc; |
| 294 | color: white; |
| 295 | border: none; |
| 296 | border-radius: 4px; |
| 297 | cursor: pointer; |
| 298 | }`; |
| 299 | |
| 300 | async getCommitHistory(initialCommit?: string): Promise<GitLogEntry[]> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 301 | console.log( |
| 302 | `[MockGitDataService] Getting commit history from ${initialCommit || "beginning"}`, |
| 303 | ); |
| 304 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 305 | // If initialCommit is provided, return commits from that commit to HEAD |
| 306 | if (initialCommit) { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 307 | const startIndex = this.mockCommits.findIndex( |
| 308 | (commit) => commit.hash === initialCommit, |
| 309 | ); |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 310 | if (startIndex >= 0) { |
| 311 | return this.mockCommits.slice(0, startIndex + 1); |
| 312 | } |
| 313 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 314 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 315 | return [...this.mockCommits]; |
| 316 | } |
| 317 | |
| 318 | async getDiff(from: string, to: string): Promise<GitDiffFile[]> { |
| 319 | console.log(`[MockGitDataService] Getting diff from ${from} to ${to}`); |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 320 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 321 | return [...this.mockDiffFiles]; |
| 322 | } |
| 323 | |
| 324 | async getCommitDiff(commit: string): Promise<GitDiffFile[]> { |
| 325 | console.log(`[MockGitDataService] Getting diff for commit ${commit}`); |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 326 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 327 | // Return a subset of files for specific commits |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 328 | if (commit === "abc123456789") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 329 | return this.mockDiffFiles.slice(0, 2); |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 330 | } else if (commit === "def987654321") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 331 | return this.mockDiffFiles.slice(1, 3); |
| 332 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 333 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 334 | // For other commits, return all files |
| 335 | return [...this.mockDiffFiles]; |
| 336 | } |
| 337 | |
| 338 | async getFileContent(fileHash: string): Promise<string> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 339 | console.log( |
| 340 | `[MockGitDataService] Getting file content for hash: ${fileHash}`, |
| 341 | ); |
| 342 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 343 | // Return different content based on the file hash |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 344 | if (fileHash === "bcd0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 345 | return this.appJSModified; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 346 | } else if (fileHash === "abc0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 347 | return this.appJSOriginal; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 348 | } else if (fileHash === "def0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 349 | return this.filePickerJS; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 350 | } else if (fileHash === "cde0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 351 | return this.rangePickerJS; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 352 | } else if (fileHash === "ghi0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 353 | return this.mainCSSModified; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 354 | } else if (fileHash === "fgh0123456789abcdef0123456789abcdef0123") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 355 | return this.mainCSSOriginal; |
| 356 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 357 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 358 | // Return empty string for unknown file hashes |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 359 | return ""; |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | async getBaseCommitRef(): Promise<string> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 363 | console.log("[MockGitDataService] Getting base commit ref"); |
| 364 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 365 | // Find the commit with the sketch-base ref |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 366 | const baseCommit = this.mockCommits.find( |
| 367 | (commit) => commit.refs && commit.refs.includes("sketch-base"), |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 368 | ); |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 369 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 370 | if (baseCommit) { |
| 371 | return baseCommit.hash; |
| 372 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 373 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 374 | // Fallback to the last commit in our list |
| 375 | return this.mockCommits[this.mockCommits.length - 1].hash; |
| 376 | } |
| 377 | |
| 378 | // Helper to simulate network delay |
| 379 | private delay(ms: number): Promise<void> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 380 | return new Promise((resolve) => setTimeout(resolve, ms)); |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 381 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 382 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 383 | async getWorkingCopyContent(filePath: string): Promise<string> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 384 | console.log( |
| 385 | `[MockGitDataService] Getting working copy content for path: ${filePath}`, |
| 386 | ); |
| 387 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 388 | // Return different content based on the file path |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 389 | if (filePath === "src/components/App.js") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 390 | return this.appJSModified; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 391 | } else if (filePath === "src/components/FilePicker.js") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 392 | return this.filePickerJS; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 393 | } else if (filePath === "src/components/RangePicker.js") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 394 | return this.rangePickerJS; |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 395 | } else if (filePath === "src/styles/main.css") { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 396 | return this.mainCSSModified; |
| 397 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 398 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 399 | // Return empty string for unknown file paths |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 400 | return ""; |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 401 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 402 | |
| 403 | async getUnstagedChanges(from: string = "HEAD"): Promise<GitDiffFile[]> { |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 404 | console.log(`[MockGitDataService] Getting unstaged changes from ${from}`); |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 405 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 406 | // Create a new array of files with 0000000... as the new hashes |
| 407 | // to simulate unstaged changes |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 408 | return this.mockDiffFiles.map((file) => ({ |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 409 | ...file, |
| Philip Zeyliger | e89b308 | 2025-05-29 03:16:06 +0000 | [diff] [blame] | 410 | new_hash: "0000000000000000000000000000000000000000", |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 411 | })); |
| 412 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 413 | |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 414 | async saveFileContent(filePath: string, content: string): Promise<void> { |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 415 | console.log( |
| 416 | `[MockGitDataService] Saving file content for path: ${filePath}`, |
| 417 | ); |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 418 | // Simulate a network delay |
| 419 | await this.delay(500); |
| 420 | // In a mock implementation, we just log the save attempt |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 421 | console.log( |
| 422 | `File would be saved: ${filePath} (${content.length} characters)`, |
| 423 | ); |
| Philip Zeyliger | 272a90e | 2025-05-16 14:49:51 -0700 | [diff] [blame] | 424 | // Return void as per interface |
| 425 | } |
| Autoformatter | 8c46362 | 2025-05-16 21:54:17 +0000 | [diff] [blame] | 426 | } |