From 2d9ade9c00f9d61b12e4e18d74f4fdbbdf97a702 Mon Sep 17 00:00:00 2001 From: prescientmoon Date: Tue, 28 May 2024 02:39:42 +0200 Subject: [PATCH] Rename github account --- README.md | 4 +- flake.lock | 4 +- flake.nix | 2 +- home/features/cli/git.nix | 2 +- home/features/neovim/config/lua/my/lazy.lua | 2 +- home/features/neovim/default.nix | 2 +- hosts/nixos/lapetus/services/homer.nix | 2 +- scripts/github/.gitignore | 1 + scripts/github/fetch-repos.sh | 3 + scripts/github/rename.py | 65 +++++++++++++++++++++ scripts/rebuild.sh | 2 + 11 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 scripts/github/.gitignore create mode 100755 scripts/github/fetch-repos.sh create mode 100755 scripts/github/rename.py create mode 100755 scripts/rebuild.sh diff --git a/README.md b/README.md index 3ddaebc..e7b6e2e 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Here's some things you might want to check out: - My [neovim config](./home/features/neovim/default.nix) - written using a [custom neovim config generation framework](./modules/common/korora-neovim.nix) - - [snippets](./home/features/neovim/snippets) written in [miros](https://github.com/mateiadrielrafael/miros) — my custom snippet generation language + - [snippets](./home/features/neovim/snippets) written in [miros](https://github.com/prescientmoon/miros) — my custom snippet generation language - The [flake](./flake.nix) entrypoint for this repository ## Things I use @@ -141,7 +141,7 @@ Includes links to stuff which used to be in the previous section but is not used - [Paperplanes.nvim](https://rktjmp/paperplanes.nvim) — replaced by a single curl call - [Eww](https://github.com/elkowar/eww) - experimented with eww for a bit, but setup was painful and bars are a bit useless - [Neogit](https://github.com/NeogitOrg/neogit) — was a bit slow / clunky, so I switched to [lazygit](https://github.com/jesseduffield/lazygit) -- [Slambda](https://github.com/Mateiadrielrafael/slambda) — custom keyboard chording utility. I retired the project in favour of [kanata](https://github.com/jtroo/kanata) +- [Slambda](https://github.com/prescientmoon/slambda) — custom keyboard chording utility. I retired the project in favour of [kanata](https://github.com/jtroo/kanata) - [GPG](https://gnupg.org/) + [pass](https://www.passwordstore.org/) — I switched to [vaultwarden](https://github.com/dani-garcia/vaultwarden/) - [Agenix](https://github.com/ryantm/agenix) & [homeage](https://github.com/jordanisaacs/homeage) — I switched to [sops-nix](https://github.com/Mic92/sops-nix) - [Mind.nvim](https://github.com/phaazon/mind.nvim) — self management tree editor. The project got archived, so I switched to [Smos](https://github.com/NorfairKing/smos). diff --git a/flake.lock b/flake.lock index 5dc98e9..347720b 100644 --- a/flake.lock +++ b/flake.lock @@ -1297,13 +1297,13 @@ "locked": { "lastModified": 1713856075, "narHash": "sha256-3nmcWGRczFJAiObkG+XUK9OdY8EVjySOUbDSK6yVyVE=", - "owner": "mateiadrielrafael", + "owner": "prescientmoon", "repo": "miros", "rev": "37081c34cb04b0751527c4ed740220c57cea3151", "type": "github" }, "original": { - "owner": "mateiadrielrafael", + "owner": "prescientmoon", "repo": "miros", "type": "github" } diff --git a/flake.nix b/flake.nix index 8102084..908c720 100644 --- a/flake.nix +++ b/flake.nix @@ -56,7 +56,7 @@ anyrun.url = "github:Kirottu/anyrun"; anyrun.inputs.nixpkgs.follows = "nixpkgs"; - miros.url = "github:mateiadrielrafael/miros"; + miros.url = "github:prescientmoon/miros"; miros.inputs.nixpkgs.follows = "nixpkgs"; # Spotify client with theming support diff --git a/home/features/cli/git.nix b/home/features/cli/git.nix index 7ae8f1d..7c73438 100644 --- a/home/features/cli/git.nix +++ b/home/features/cli/git.nix @@ -42,7 +42,7 @@ # }}} extraConfig = { - github.user = "Mateiadrielrafael"; + github.user = "prescientmoon"; hub.protocol = "ssh"; core.editor = "nvim"; init.defaultBranch = "main"; diff --git a/home/features/neovim/config/lua/my/lazy.lua b/home/features/neovim/config/lua/my/lazy.lua index 01ee65c..7c31eb7 100644 --- a/home/features/neovim/config/lua/my/lazy.lua +++ b/home/features/neovim/config/lua/my/lazy.lua @@ -27,7 +27,7 @@ function M.setup() -- Directory where I store my local plugin projects path = vim.g.nix_projects_path, - patterns = { "Mateiadrielrafael" }, + patterns = { "prescientmoon" }, }, performance = { rtp = { diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix index 4cf1857..cc93771 100644 --- a/home/features/neovim/default.nix +++ b/home/features/neovim/default.nix @@ -335,7 +335,7 @@ let # }}} # {{{ scrap scrap = { - package = "mateiadrielrafael/scrap.nvim"; + package = "prescientmoon/scrap.nvim"; event = "InsertEnter"; config.setup."my.abbreviations" = true; diff --git a/hosts/nixos/lapetus/services/homer.nix b/hosts/nixos/lapetus/services/homer.nix index e71f87e..4d5f93b 100644 --- a/hosts/nixos/lapetus/services/homer.nix +++ b/hosts/nixos/lapetus/services/homer.nix @@ -78,7 +78,7 @@ in name = "Dotfiles"; subtitle = "Configuration for all my machines"; logo = icon "github.png"; - url = "https://github.com/mateiadrielrafael/everything-nix"; + url = "https://github.com/prescientmoon/everything-nix"; } { name = "Cloudflare"; diff --git a/scripts/github/.gitignore b/scripts/github/.gitignore new file mode 100644 index 0000000..f500967 --- /dev/null +++ b/scripts/github/.gitignore @@ -0,0 +1 @@ +repos.json diff --git a/scripts/github/fetch-repos.sh b/scripts/github/fetch-repos.sh new file mode 100755 index 0000000..064919e --- /dev/null +++ b/scripts/github/fetch-repos.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +gh repo list --limit 200 --json name,description,url,sshUrl,owner,visibility,isArchived,isFork \ + | jq > ./repos.json diff --git a/scripts/github/rename.py b/scripts/github/rename.py new file mode 100755 index 0000000..7ddc8d2 --- /dev/null +++ b/scripts/github/rename.py @@ -0,0 +1,65 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p python3 -i python3 +import json +import os +import subprocess +import tempfile +import shutil + +file_path = './repos.json' +general_org = "temporarymoon" # Get it? Because forks involve many trees, which like, form a canopy or whatever... :/ +fork_org = "starlitcanopy" +future_name = "prescientmoon" +current_name = "mateiadrielrafael" + +with open(file_path, 'r') as file: + data = json.load(file) + +print(f"Parsed {len(data)} repos") + +with tempfile.TemporaryDirectory() as temp_dir: + print(f"Temporary directory: {temp_dir}") + for repo in data: + name = repo["name"] + url = repo["url"] + org = fork_org if repo['isFork'] else general_org + fork = f"{org}/{name}" + + os.chdir(temp_dir) + + if repo["isFork"]: + subprocess.run(f"gh api repos/{current_name}/{name}/transfer -f new_owner={org}", shell=True) + else: + subprocess.run(f"gh repo fork {url} --clone --org {org} --default-branch-only", shell=True) + os.chdir(f"{temp_dir}/{name}") + + # Create the readme if it doesn't exist + if not os.path.exists("README.md"): + with open("README.md", 'w') as file: + file.write('') + + # Read the existing content of the readme + with open("README.md", 'r') as file: + existing_content = file.read() + + future = f"{future_name}/{name}" + + # Add disclaimer at top + text_to_prepend = f"# 🚧 This repo has been moved to [{future}](https://github.com/{future}) 🚧\n" + + with open("README.md", 'w') as file: + file.write(text_to_prepend + existing_content) + + # Commit changes + subprocess.run("git add .", shell=True) + subprocess.run("git commit -m 'Added movement notice to readme [skip-ci]'", shell=True) + subprocess.run("git push", shell=True) + + # Fix visibility and archive repo + visibility = repo["visibility"] + if visibility != "public": + subprocess.run(f"gh repo edit {fork} --visibility {visibility}", shell=True) + subprocess.run(f"gh repo archive {fork} --yes", shell=True) + shutil.rmtree(f"{temp_dir}/{name}") + + print(f"Done moving to {fork}") diff --git a/scripts/rebuild.sh b/scripts/rebuild.sh new file mode 100755 index 0000000..3c9c12d --- /dev/null +++ b/scripts/rebuild.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +sudo nixos-rebuild switch --flake .#$hostname --show-trace --fast