feat: initial commit
Signed-off-by: Vojtěch Mareš <vojtech@mares.cz>
This commit is contained in:
commit
ba2959b683
9 changed files with 180 additions and 0 deletions
35
src/main.ts
Normal file
35
src/main.ts
Normal 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();
|
||||
Reference in a new issue