From 6a7b8286306d26a138ced9093e5b05ad97e5ed5e Mon Sep 17 00:00:00 2001 From: brent s Date: Sun, 3 Jan 2021 03:39:41 -0500 Subject: [PATCH] some cleanup/maintenance --- .gitmodules | 9 --------- _bin/remove.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100755 _bin/remove.py diff --git a/.gitmodules b/.gitmodules index b6806aa..953eaf8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,15 +52,6 @@ [submodule "mdcrack"] path = mdcrack url = aur@aur.archlinux.org:mdcrack -[submodule "mindi"] - path = mindi - url = aur@aur.archlinux.org:mindi -[submodule "mindi-busybox"] - path = mindi-busybox - url = aur@aur.archlinux.org:mindi-busybox -[submodule "mondo"] - path = mondo - url = aur@aur.archlinux.org:mondo [submodule "nquake"] path = nquake url = aur@aur.archlinux.org:nquake diff --git a/_bin/remove.py b/_bin/remove.py new file mode 100755 index 0000000..5ea20d8 --- /dev/null +++ b/_bin/remove.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +import argparse +import os +import shutil +## +import git + + +repo_dir = '/opt/dev/arch' + +class Remover(object): + def __init__(self, pkgnm, force = False): + self.pkg = pkgnm + self.force = force + rdir = os.path.abspath(os.path.expanduser(repo_dir)) + self.dir = os.path.join(rdir, self.pkg) + # TODO: automatically check out? + if not os.path.isdir(self.dir): + raise FileNotFoundError('Package directory does not exist. Is it checked out?') + self.repo = git.Repo(rdir) + self.sub = self.repo.submodule(self.pkg) + + def remove(self): + self.sub.remove(force = self.force) + return(None) + + def push(self): + self.repo.remotes.origin.push() + return(None) + + +def parseArgs(): + args = argparse.ArgumentParser(description = 'Remove a package from repository (disowned, promoted to [community], etc.)') + args.add_argument('-f', '--force', + action = 'store_true', + help = 'Delete even if it contains changes not yet committed') + args.add_argument('pkgnm', + help = 'The package name. An error will be thrown if it is not checked out locally') + return(args) + + +def main(): + args = parseArgs().parse_args() + r = Remover(**vars(args)) + r.remove() + r.push() + return(None) + + +if __name__ == '__main__': + main() +