Skip to content

Commit

Permalink
fix: Use default branch for unpublished Cargo deps (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz authored Mar 26, 2024
1 parent 68722f2 commit 55eb74d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
21 changes: 13 additions & 8 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82328,13 +82328,13 @@ async function main(input) {
for (const repo of input.unpublishedDepsRepos) {
await publishToEstuary(input, repo, registry, /^$/);
}
await publishToEstuary(input, input.repo, registry, input.unpublishedDepsRegExp);
await publishToEstuary(input, input.repo, registry, input.unpublishedDepsRegExp, input.branch);
await deleteRepos(input);
if (input.liveRun) {
for (const repo of input.unpublishedDepsRepos) {
publishToCratesIo(input, repo);
}
publishToCratesIo(input, input.repo);
publishToCratesIo(input, input.repo, input.branch);
}
await cleanup(input, registry);
}
Expand All @@ -82358,9 +82358,14 @@ async function cleanup(input, registry) {
}
await deleteRepos(input);
}
function clone(input, repo) {
function clone(input, repo, branch) {
const remote = `https://${input.githubToken}@github.com/${repo}.git`;
sh(`git clone --recursive --single-branch --branch ${input.branch} ${remote}`);
if (branch == undefined) {
sh(`git clone --recursive ${remote}`);
}
else {
sh(`git clone --recursive --single-branch --branch ${branch} ${remote}`);
}
}
async function deleteRepos(input) {
lib_core.info(`Deleting repository clone ${repoPath(input.repo)}`);
Expand All @@ -82373,8 +82378,8 @@ async function deleteRepos(input) {
function repoPath(repo) {
return repo.split("/").at(1);
}
async function publishToEstuary(input, repo, registry, registryDepsRegExp) {
clone(input, repo);
async function publishToEstuary(input, repo, registry, registryDepsRegExp, branch) {
clone(input, repo, branch);
const path = repoPath(input.repo);
await configRegistry(path, registry.name, registry.index);
await setRegistry(path, registryDepsRegExp, registry.name);
Expand All @@ -82384,8 +82389,8 @@ async function publishToEstuary(input, repo, registry, registryDepsRegExp) {
};
publish(path, env);
}
function publishToCratesIo(input, repo) {
clone(input, repo);
function publishToCratesIo(input, repo, branch) {
clone(input, repo, branch);
const path = repoPath(input.repo);
const env = {
CARGO_REGISTRY_TOKEN: input.cratesIoToken,
Expand Down
20 changes: 13 additions & 7 deletions src/publish-crates-cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function main(input: Input) {
await publishToEstuary(input, repo, registry, /^$/);
}

await publishToEstuary(input, input.repo, registry, input.unpublishedDepsRegExp);
await publishToEstuary(input, input.repo, registry, input.unpublishedDepsRegExp, input.branch);

await deleteRepos(input);

Expand All @@ -55,7 +55,7 @@ export async function main(input: Input) {
publishToCratesIo(input, repo);
}

publishToCratesIo(input, input.repo);
publishToCratesIo(input, input.repo, input.branch);
}

await cleanup(input, registry);
Expand All @@ -80,9 +80,14 @@ export async function cleanup(input: Input, registry: estuary.Estuary) {
await deleteRepos(input);
}

function clone(input: Input, repo: string): void {
function clone(input: Input, repo: string, branch?: string): void {
const remote = `https://${input.githubToken}@github.com/${repo}.git`;
sh(`git clone --recursive --single-branch --branch ${input.branch} ${remote}`);

if (branch == undefined) {
sh(`git clone --recursive ${remote}`);
} else {
sh(`git clone --recursive --single-branch --branch ${branch} ${remote}`);
}
}

async function deleteRepos(input: Input) {
Expand All @@ -104,8 +109,9 @@ async function publishToEstuary(
repo: string,
registry: estuary.Estuary,
registryDepsRegExp: RegExp,
branch?: string,
): Promise<void> {
clone(input, repo);
clone(input, repo, branch);
const path = repoPath(input.repo);

await cargo.configRegistry(path, registry.name, registry.index);
Expand All @@ -119,8 +125,8 @@ async function publishToEstuary(
publish(path, env);
}

function publishToCratesIo(input: Input, repo: string) {
clone(input, repo);
function publishToCratesIo(input: Input, repo: string, branch?: string) {
clone(input, repo, branch);
const path = repoPath(input.repo);

const env = {
Expand Down

0 comments on commit 55eb74d

Please sign in to comment.