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