some cleanup/maintenance

This commit is contained in:
brent s. 2021-01-03 03:39:41 -05:00
parent d237bdc189
commit 6a7b828630
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 53 additions and 9 deletions

9
.gitmodules vendored
View File

@ -52,15 +52,6 @@
[submodule "mdcrack"] [submodule "mdcrack"]
path = mdcrack path = mdcrack
url = aur@aur.archlinux.org: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"] [submodule "nquake"]
path = nquake path = nquake
url = aur@aur.archlinux.org:nquake url = aur@aur.archlinux.org:nquake

53
_bin/remove.py Executable file
View File

@ -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()