(credentialsId?: string | null)
| 1264 | } |
| 1265 | |
| 1266 | async pullWithConflictSupport(credentialsId?: string | null) { |
| 1267 | const hasUncommittedChanges = await this.hasUncommittedChanges(); |
| 1268 | |
| 1269 | if (hasUncommittedChanges) { |
| 1270 | throw new Error(GitVCSOperationErrors.UncommittedChangesError); |
| 1271 | } |
| 1272 | |
| 1273 | const writeFileMap = {}; |
| 1274 | |
| 1275 | try { |
| 1276 | if ( |
| 1277 | 'startCollectWriteAction' in this._baseOpts.fs && |
| 1278 | typeof this._baseOpts.fs.startCollectWriteAction === 'function' |
| 1279 | ) { |
| 1280 | this._baseOpts.fs.startCollectWriteAction(writeFileMap); |
| 1281 | } |
| 1282 | // Try to pull changes from the remote repository |
| 1283 | await git.pull({ |
| 1284 | ...this._baseOpts, |
| 1285 | ...gitCallbacks(credentialsId), |
| 1286 | remote: 'origin', |
| 1287 | singleBranch: true, |
| 1288 | }); |
| 1289 | |
| 1290 | return { success: true }; |
| 1291 | } catch (err) { |
| 1292 | if (err instanceof git.Errors.CheckoutConflictError) { |
| 1293 | console.log('[git] CheckoutConflictError detected, resetting working directory and retrying pull'); |
| 1294 | |
| 1295 | try { |
| 1296 | const currentBranch = await this.getCurrentBranch(); |
| 1297 | |
| 1298 | // Reset working directory to HEAD to resolve checkout conflicts |
| 1299 | await git.checkout({ |
| 1300 | ...this._baseOpts, |
| 1301 | ref: currentBranch, |
| 1302 | force: true, |
| 1303 | }); |
| 1304 | |
| 1305 | // Retry the pull operation |
| 1306 | await git.pull({ |
| 1307 | ...this._baseOpts, |
| 1308 | ...gitCallbacks(credentialsId), |
| 1309 | remote: 'origin', |
| 1310 | singleBranch: true, |
| 1311 | ref: currentBranch, |
| 1312 | }); |
| 1313 | |
| 1314 | console.log('[git] Pull successful after resolving checkout conflicts'); |
| 1315 | return { success: true }; |
| 1316 | } catch (retryError) { |
| 1317 | console.error('[git] Retry pull failed after resolving checkout conflicts:', retryError); |
| 1318 | |
| 1319 | const handledError = await this.handleGitPullErrors(err, credentialsId, writeFileMap); |
| 1320 | |
| 1321 | if (handledError) { |
| 1322 | return handledError; |
| 1323 | } |
no test coverage detected