Skip to content

Commit

Permalink
Merge pull request #561 from vtex/add/resolve-all-to-conflicts-resolver
Browse files Browse the repository at this point in the history
Add resolveAll to the ConflicstResolver module
  • Loading branch information
iagoaraujo authored Oct 23, 2024
2 parents 4a5bff1 + 1c052c4 commit 9924145
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- resolveAll to `MineWinsConflictsResolver` to handle an array of conflicts.

## [6.47.0] - 2024-06-11
### Added
- Add option to save asynchronous cache
Expand Down
14 changes: 14 additions & 0 deletions src/utils/MineWinsConflictsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ export class MineWinsConflictsResolver<T> implements ConflictsResolver<T> {
})
}

public async resolveAll() {
const conflictsResponse = await this.client.getConflicts<AxiosResponse<VBaseConflictData[]>>(this.bucket)
const { data: conflicts }: { data: VBaseConflictData[] } = conflictsResponse

const resolvedConflicts = conflicts.map((conflict) => {
conflict.base.parsedContent = this.parseConflict(conflict.base)
conflict.master.parsedContent = this.parseConflict(conflict.master)
conflict.mine.parsedContent = this.parseConflict(conflict.mine)
return this.resolveConflictMineWins(conflict)
})

return resolvedConflicts
}

protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration) {
if (isArray(master)) {
return this.mergeMineWinsArray((base || []) as ConfigurationData[], master, (mine || []) as ConfigurationData[])
Expand Down

0 comments on commit 9924145

Please sign in to comment.