Example #1
0
    def setUp(self):
        debug.set_debug(False)
        self.tempdir = tempfile.mkdtemp()
        self.orig_cwd = os.getcwd()
        os.chdir(self.tempdir)
        self.repopath = os.path.join(self.tempdir, "origin")
        Git.create_repo(self.repopath, bare=True)
        self.git = Git(self.repopath)

        self.clone_path = os.path.join(self.tempdir, "clone")
        self.git.clone_to(self.clone_path)
        self.gitclone = Git(self.clone_path)
        self.create_file(os.path.join(self.clone_path, "initial"))
        self.gitclone.add("initial")
        self.gitclone.commit("message")
        self.gitclone.push_master()
Example #2
0
def init_git(cfg, args):
    datapath = cfg['global']['datapath']
    if os.path.isdir(os.path.join(datapath, ".git")):
        sys.exit(
            '{} is already a git repo! Not reinitializing to avoid losing data.'
            .format(datapath))

    os.makedirs(datapath, exist_ok=True)
    Git.create_repo(datapath, bare=False)
    fn = os.path.join(datapath, '.gitignore')
    with open(fn, 'x') as f:
        f.write('lock\n')
    git = Git(datapath)
    git.add('.gitignore')
    git.commit('Initial')
    print('Password storage git repo initialized in {}'.format(datapath))