def cmd_init(args): """Usage: init Initialize an empty plaur repository in the current working directory""" git_path = gitwrapper.detect_git(); if git_path != None: raise UserErrorMessage("Already a git repository in »%s«" % git_path) git = gitwrapper.Git(os.getcwd()) out = git.call_success('init'); global config config.set_filename_from_git(git) config.read() config.write() git.call_success("add", config.filename) # create empty packages file p = packageconfig.PackageConfig(git) p.read() p.write() git.call_success("add", p.absolute_filepath()) git.call_success("commit", "-m", "Initial commit");
def assert_plaur_git(): gitpath = gitwrapper.detect_git(); if gitpath == None: raise UserErrorMessage("Not in a plaur git repository") git = plaur.gitwrapper.Git(gitpath) if not git.is_plaur_repo(): # if this detected git is not a plaur repository, # then maybe it's just a pkgbuild repo, so try the parent directory as # well: (gitpath,_) = os.path.split(gitpath.rstrip('/')) gitpath = gitwrapper.detect_git(cwd=gitpath) if gitpath == None: raise UserErrorMessage("Not in a plaur git repository") git = plaur.gitwrapper.Git(gitpath) if not git.is_plaur_repo(): raise UserErrorMessage("Present directory is not in a plaur repository") #print(gitpath) global config config.set_filename_from_git(git) return git