Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/core/test/vcs-hg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ describeHg("Vcs mercurial", () => {
})
const vcs = yield* Vcs.Service
const bus = yield* Bus.Service
expect(yield* vcs.info()).toEqual({ branch: { current: "default", default: "default" } })
expect(yield* vcs.info()).toEqual({ provider: "hg", branch: { current: "default", default: "default" } })

const updated = yield* bus
.subscribe(VcsEvent.BranchUpdated)
.pipe(Stream.take(1), Stream.runHead, Effect.forkScoped({ startImmediately: true }))
yield* Effect.promise(() => hg(directory, "branch", "-q", "feature"))
expect(yield* vcs.info()).toEqual({ branch: { current: "default", default: "default" } })
expect(yield* vcs.info()).toEqual({ provider: "hg", branch: { current: "default", default: "default" } })

yield* bus.publish(FileSystem.Event.Changed, {
file: path.join(directory, ".hg", "branch"),
Expand All @@ -167,7 +167,7 @@ describeHg("Vcs mercurial", () => {
_tag: "Some",
value: { location: { directory }, data: { branch: "feature" } },
})
expect(yield* vcs.info()).toEqual({ branch: { current: "feature", default: "default" } })
expect(yield* vcs.info()).toEqual({ provider: "hg", branch: { current: "feature", default: "default" } })
}),
),
)
Expand Down
20 changes: 10 additions & 10 deletions packages/core/test/vcs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe("Vcs", () => {
editor.default.set("custom")
})

expect(yield* vcs.info()).toEqual({ branch: { current: "feature", default: "main" } })
expect(yield* vcs.info()).toEqual({ provider: "custom", branch: { current: "feature", default: "main" } })
expect(yield* vcs.base()).toBeNull()
expect(yield* vcs.branches()).toEqual(["feature", "main"])
expect(yield* vcs.status()).toEqual([{ file: "file.txt", additions: 1, deletions: 0, status: "added" }])
Expand All @@ -146,10 +146,10 @@ describe("Vcs", () => {
Effect.gen(function* () {
const vcs = yield* Vcs.Service
const registration = yield* vcs.transform((editor) => editor.add(provider({ id: "git" })))
expect(yield* vcs.info()).toEqual({ branch: { current: "feature", default: "main" } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "feature", default: "main" } })

yield* registration.dispose
expect(yield* vcs.info()).toEqual({ branch: { current: "main", default: undefined } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "main", default: undefined } })
}),
),
)
Expand Down Expand Up @@ -188,7 +188,7 @@ describe("Vcs", () => {
}),
)
expect(reads).toEqual(["final"])
expect(yield* vcs.info()).toEqual({ branch: { current: "final" } })
expect(yield* vcs.info()).toEqual({ provider: "custom", branch: { current: "final" } })
}),
)

Expand Down Expand Up @@ -456,7 +456,7 @@ describe("Vcs", () => {
),
)
expect((yield* vcs.status())[0]?.file).toBe("config.txt")
expect(yield* vcs.info()).toEqual({ branch: { current: "initial" } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "initial" } })
yield* Deferred.succeed(accepted, undefined)
}),
).pipe(Effect.forkScoped({ startImmediately: true }))
Expand All @@ -466,7 +466,7 @@ describe("Vcs", () => {
yield* Deferred.succeed(release, undefined)
yield* Fiber.join(configured)
expect(Option.getOrUndefined(yield* Fiber.join(updates))?.data.branch).toBe("config")
expect(yield* vcs.info()).toEqual({ branch: { current: "config" } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "config" } })
expect(reads).toEqual(["initial", "filesystem", "config"])
}).pipe(Effect.ensuring(Deferred.succeed(release, undefined)))
}),
Expand Down Expand Up @@ -502,7 +502,7 @@ describe("Vcs", () => {
})
yield* bus.publish(Done, {})
const events = (yield* Fiber.join(updates)).filter((event) => event.type === VcsEvent.BranchUpdated.type)
expect(yield* vcs.info()).toEqual({ branch: { current: "listener" } })
expect(yield* vcs.info()).toEqual({ provider: "custom", branch: { current: "listener" } })
expect(events.length).toBeGreaterThanOrEqual(2)
expect(events.at(-1)?.data.branch).toBe((yield* vcs.info()).branch.current)
}).pipe(Effect.ensuring(unsubscribe))
Expand Down Expand Up @@ -567,22 +567,22 @@ describe("Vcs", () => {
})
const vcs = yield* Vcs.Service
const bus = yield* Bus.Service
expect(yield* vcs.info()).toEqual({ branch: { current: "main", default: undefined } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "main", default: undefined } })

const updated = yield* bus
.subscribe(VcsEvent.BranchUpdated)
.pipe(Stream.take(1), Stream.runHead, Effect.forkScoped({ startImmediately: true }))
yield* Effect.promise(() => $`git checkout -q -b feature`.cwd(directory).quiet())

yield* bus.publish(FileSystem.Event.Changed, { file: path.join(directory, "HEAD"), event: "change" })
expect(yield* vcs.info()).toEqual({ branch: { current: "main", default: undefined } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "main", default: undefined } })

yield* bus.publish(FileSystem.Event.Changed, { file: path.join(directory, ".git", "HEAD"), event: "change" })
expect(yield* Fiber.join(updated)).toMatchObject({
_tag: "Some",
value: { location: { directory }, data: { branch: "feature" } },
})
expect(yield* vcs.info()).toEqual({ branch: { current: "feature", default: "main" } })
expect(yield* vcs.info()).toEqual({ provider: "git", branch: { current: "feature", default: "main" } })
}),
),
)
Expand Down
Loading