1
0
Fork 0

feat: initial commit

Signed-off-by: Vojtěch Mareš <vojtech@mares.cz>
This commit is contained in:
Vojtěch Mareš 2025-05-17 08:43:13 +02:00
commit ba2959b683
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
9 changed files with 180 additions and 0 deletions

35
src/main.ts Normal file
View file

@ -0,0 +1,35 @@
import { $ } from "bun";
import { repositories } from "../repositories.json"
async function main() {
const workspace = (await $`pwd`.text()).replaceAll("\n", "");
for (const repo of repositories) {
// clone remote repository (source repository)
const repoName = repo.src.split("@")[1];
if (!repoName) {
continue;
}
console.log(`Cloning ${repoName}...`);
await $`git clone ${repo.src} repo`;
await $.cwd("repo");
await $`git remote rename origin upstream`;
await $`git remote add origin ${repo.dest}`;
await $`git fetch upstream`;
await $`git fetch origin`;
const branch = (await $`git branch --show-current`.text()).replaceAll("\n", "");
await $`git switch -c upstream/${branch}`;
await $`git push -u origin upstream/${branch}`;
// clean up
await $.cwd(workspace);
await $`rm -rf repo`;
}
}
await main();