Skip to content

Commit

Permalink
Move the conflicts resolution logic inside the checkForConflicts cond…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
vitorflg committed Oct 10, 2024
1 parent b2056e6 commit fcfc225
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/modules/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ const throwIfIsMaster = (workspace: string) => {
}
}

/* This function is very specific to solve conflicts in the pages graphql app.
The primary conflict resolution strategy at the file level
is insufficient for safely resolving conflicts in the pages GraphQL application.
All conflicts resolved here is using a mineWins strategy at the content json level.
*/
const handleConflict = async () => {
const conflictsFound = await vbase.checkForConflicts()
const conflictsFoundForPagesGraphql = await vbase.checkForConflicts()

if (conflictsFound) {
await axios.get(workspaceUrl)
}
if (!conflictsFoundForPagesGraphql) return

// Forcing rebase to avoid conflicts
await axios.get(workspaceUrl)

// @vtex/api expects a full implementation of the client, so we need to cast it to any.
// The partial implementation is enough to solve conflicts.
const conflictsResolver = new MineWinsConflictsResolver((vbase as Partial<VBase>) as any, 'userData', '')

await conflictsResolver.resolveAll()
return conflictsResolver.resolveAll()
}

const isPromotable = async (workspace: string) => {
Expand Down

0 comments on commit fcfc225

Please sign in to comment.