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
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,41 @@ describe("AzureDevOpsCli.layer", () => {
}).pipe(Effect.provide(layer)),
);

it.effect("looks up a project/repository path as that project's repository", () =>
Effect.gen(function* () {
mockRun.mockReturnValueOnce(
Effect.succeed(
processOutput(
JSON.stringify({
name: "repo",
webUrl: "https://dev.azure.com/acme/project/_git/repo",
remoteUrl: "https://dev.azure.com/acme/project/_git/repo",
sshUrl: "git@ssh.dev.azure.com:v3/acme/project/repo",
project: { name: "project" },
}),
),
),
);

const az = yield* AzureDevOpsCli.AzureDevOpsCli;
yield* az.getRepositoryCloneUrls({ cwd: "/somewhere", repository: "project/repo" });

assert.deepStrictEqual(mockRun.mock.calls.at(-1)?.[0].args, [
"repos",
"show",
"--detect",
"true",
"--repository",
"repo",
"--project",
"project",
"--only-show-errors",
"--output",
"json",
]);
}).pipe(Effect.provide(layer)),
);

it.effect("preserves VCS causes without copying upstream details into messages", () =>
Effect.gen(function* () {
const cause = new VcsProcessExitError({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,18 @@ export const make = Effect.gen(function* () {
);
}),
getRepositoryCloneUrls: Effect.fn("AzureDevOpsCli.getRepositoryCloneUrls")(function (input) {
const repository = parseRepositorySpecifier(input.repository);
return executeJson({
cwd: input.cwd,
args: ["repos", "show", "--detect", "true", "--repository", input.repository],
args: [
"repos",
"show",
"--detect",
"true",
"--repository",
repository.name,
...(repository.project ? ["--project", repository.project] : []),
],
}).pipe(
Effect.map((result) => result.stdout.trim()),
Effect.flatMap((raw) =>
Expand Down
Loading