buddy-workbench 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buddy-workbench",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -144,7 +144,14 @@ async function readGitFile(folder, ref, filePath) {
144
144
  }
145
145
 
146
146
  function pathOf(change) {
147
- return change?.path?.toString || change?.path?.name || change?.path || change?.src?.toString || '';
147
+ const path = change?.path;
148
+ if (typeof path === 'string') return path;
149
+ if (typeof path?.toString === 'function') return path.toString();
150
+ if (Array.isArray(path?.components)) return path.components.join('/');
151
+ if (typeof path?.name === 'string') return path.name;
152
+ if (typeof path?.src === 'string') return path.src;
153
+ if (typeof path?.src?.toString === 'string') return path.src.toString;
154
+ return '';
148
155
  }
149
156
 
150
157
  function extractTextFromContent(data) {
@@ -248,7 +255,7 @@ export function UserProfile({ userId }: { userId: string }) {
248
255
  </Card>
249
256
  );
250
257
  }`,
251
- defaultChoice: 'source'
258
+ defaultChoice: 'target'
252
259
  },
253
260
  {
254
261
  path: 'src/config/application-settings.json',
@@ -282,8 +289,10 @@ export function UserProfile({ userId }: { userId: string }) {
282
289
  const changes = changesResponse.data?.values || [];
283
290
  const sourceCommit = pr.fromRef?.latestCommit || pr.fromRef?.id;
284
291
  const targetCommit = pr.toRef?.latestCommit || pr.toRef?.id;
285
- let conflictedPaths = null;
286
- if (mergeResponse.data?.conflicted) {
292
+ const hasConflicts = Boolean(mergeResponse.data?.conflicted);
293
+ const apiConflictedPaths = new Set(changes.filter((change) => change?.conflict).map(pathOf).filter(Boolean));
294
+ let conflictedPaths = apiConflictedPaths.size ? apiConflictedPaths : null;
295
+ if (hasConflicts && !conflictedPaths) {
287
296
  try {
288
297
  const folder = await findWorkspaceRepository(parsed);
289
298
  await git(folder, ['fetch', 'origin', '--prune']);
@@ -294,14 +303,13 @@ export function UserProfile({ userId }: { userId: string }) {
294
303
  }
295
304
  const files = await Promise.all(changes.map(async (change) => {
296
305
  const path = pathOf(change);
297
- if (conflictedPaths && !conflictedPaths.has(path)) return null;
298
306
  const [sourceContent, targetContent] = await Promise.all([
299
307
  readFile({ ...parsed, commit: sourceCommit, path }),
300
308
  readFile({ ...parsed, commit: targetCommit, path })
301
309
  ]);
302
- return { path, sourceContent, targetContent, defaultChoice: 'source' };
310
+ return { path, sourceContent, targetContent, changeType: change.type, defaultChoice: 'target' };
303
311
  }));
304
- res.json({ conflicted: Boolean(mergeResponse.data.conflicted), pr: { title: pr.title, sourceBranch: pr.fromRef?.displayId, targetBranch: pr.toRef?.displayId }, files: files.filter((file) => file?.path).map((file) => ({ ...file, conflicted: conflictedPaths ? conflictedPaths.has(file.path) : true })) });
312
+ res.json({ conflicted: hasConflicts, pr: { title: pr.title, sourceBranch: pr.fromRef?.displayId, targetBranch: pr.toRef?.displayId }, files: files.filter((file) => file?.path).map((file) => ({ ...file, conflicted: Boolean(conflictedPaths?.has(file.path)) })) });
305
313
  } catch (error) {
306
314
  res.status(500).json({ error: `Unable to load conflict data: ${error.message}` });
307
315
  }
@@ -534,9 +542,14 @@ router.post('/resolve', async (req, res) => {
534
542
  let resolutionPrUrl = '';
535
543
  if (createNewBranch) {
536
544
  const createPrUrl = `https://${parsed.host}/rest/api/latest/projects/${encodeURIComponent(parsed.projectKey)}/repos/${encodeURIComponent(parsed.repositorySlug)}/pull-requests`;
545
+ const conflictFileSummary = files.map((file, index) => {
546
+ const filePath = validateRelativeFilePath(file.path);
547
+ const resolvedBranch = choices[file.path] === 'target' ? targetBranch : sourceBranch;
548
+ return `${index + 1}. \`${filePath}\` uses \`${resolvedBranch}\``;
549
+ }).join('\n');
537
550
  const createPrResponse = await client.post(createPrUrl, {
538
551
  title: commitMessage,
539
- description: `Resolution Pull Request created from ${commitBranch}.\n\nThis branch resolves conflicts for Pull Request #${parsed.pullRequestId} (${sourceBranch} → ${targetBranch}).`,
552
+ description: `Resolution Pull Request created from ${commitBranch}.\n\nThis branch resolves conflicts for Pull Request #${parsed.pullRequestId} (${sourceBranch} → ${targetBranch}).\n\n## conflict files\n\n${conflictFileSummary}`,
540
553
  fromRef: {
541
554
  id: `refs/heads/${commitBranch}`,
542
555
  repository: { slug: parsed.repositorySlug, project: { key: parsed.projectKey } }