some cleanup/maintenance

master
brent s. 2 years ago
parent d237bdc189
commit 6a7b828630
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
  1. 9
      .gitmodules
  2. 53
      _bin/remove.py

9
.gitmodules vendored

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

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

Loading…
Cancel
Save