Hey is a decentralized and permissionless social media app built with Lens Protocol 馃尶
1#!/usr/bin/env node
2import { execSync } from "node:child_process";
3
4function run(command) {
5 execSync(command, { stdio: "inherit" });
6}
7
8function getLocalBranches() {
9 const output = execSync("git branch", { encoding: "utf8" });
10 return output
11 .split("\n")
12 .map((b) => b.replace("*", "").trim())
13 .filter(Boolean);
14}
15
16console.log("Deleting all branches except 'main' \ud83d\uddd1");
17const branches = getLocalBranches().filter((b) => b !== "main");
18for (const branch of branches) {
19 run(`git branch -D ${branch}`);
20}
21
22console.log("Deleting branches that no longer exist on remote \ud83d\uddd1");
23run("git fetch -p");
24const goneOutput = execSync(
25 "git for-each-ref --format='%(refname) %(upstream:track)' refs/heads",
26 { encoding: "utf8" }
27);
28const goneBranches = goneOutput
29 .split("\n")
30 .filter(Boolean)
31 .map((line) => line.trim().split(" "))
32 .filter(([, status]) => status === "[gone]")
33 .map(([ref]) => ref.replace("refs/heads/", ""));
34for (const branch of goneBranches) {
35 run(`git branch -D ${branch}`);
36}
37console.log("Branches deleted \ud83c\udf89");