@cueloop/client 0.1.0-alpha.89 → 0.1.0-alpha.90

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.
@@ -1,9 +1,19 @@
1
- import { recaptureMainHead, type DiffFileContents, type Thread } from "@cueloop/schema";
1
+ import {
2
+ recaptureMainHead,
3
+ type DiffFileContents,
4
+ type DiffSource,
5
+ type Thread,
6
+ } from "@cueloop/schema";
2
7
 
3
8
  /** Reads the live working-tree diff for a repo root (the daemon's `repo.diff` RPC). */
4
- export type RepoDiff = (repoRoot: string) => Promise<{
9
+ export type RepoDiff = (
10
+ repoRoot: string,
11
+ vcs?: string,
12
+ ) => Promise<{
5
13
  patch: string;
6
14
  files: DiffFileContents[];
15
+ source?: Omit<DiffSource, "vcs">;
16
+ vcs?: string;
7
17
  }>;
8
18
 
9
19
  /**
@@ -15,15 +25,35 @@ export type RepoDiff = (repoRoot: string) => Promise<{
15
25
  export async function snapshotWorkbench(session: Thread, repoDiff: RepoDiff): Promise<Thread> {
16
26
  if (session.artifact.type !== "diff" || session.artifact.meta.workbench !== true) return session;
17
27
 
18
- const { patch, files } = await repoDiff(session.workspace.repoRoot);
28
+ const { patch, files, source, vcs } = await repoDiff(
29
+ session.workspace.repoRoot,
30
+ session.artifact.meta.vcs,
31
+ );
32
+ const provider = vcs ?? session.artifact.meta.vcs;
19
33
  const artifact = {
20
34
  ...session.artifact,
21
35
  content: patch,
22
36
  files,
23
- meta: { ...session.artifact.meta, snapshot: true },
37
+ meta: {
38
+ ...session.artifact.meta,
39
+ snapshot: true,
40
+ vcs: provider,
41
+ vcsChangeId: source?.changeId,
42
+ vcsRevisionId: source?.revisionId,
43
+ },
24
44
  };
25
45
  // the share path rebuilds content from history; recapture the branch head so it matches the fresh patch
26
46
  const history = session.history ? recaptureMainHead(session.history, patch) : session.history;
47
+ const revisions = session.revisions.map((revision, index) =>
48
+ index === session.revisions.length - 1
49
+ ? {
50
+ ...revision,
51
+ content: patch,
52
+ files,
53
+ source: provider && source ? { vcs: provider, ...source } : undefined,
54
+ }
55
+ : revision,
56
+ );
27
57
 
28
- return { ...session, artifact, history };
58
+ return { ...session, artifact, history, revisions };
29
59
  }