예제 #1
0
    def update(self, msg, matches):
        repos = self._get_repos_from_config()

        if not repos:
            self.respond_to_msg(msg, "Warning: there are no repos in the configuration")
            return

        pkg_repo_dir = Path(PKG_REPO_DIR)
        if not pkg_repo_dir.exists():
            pkg_repo_dir.mkdir(parents=True)

        for repo_name, url in repos.items():
            gs = None
            if repo_name not in self._installed_repos():
                gs = git.clone(url, directory=repo_name, cwd=PKG_REPO_DIR)
            else:
                repo_path = self._repo_path(repo_name)
                git.reset(cwd=repo_path, hard=True)
                gs = git.pull(cwd=repo_path)

            if not gs:
                self.respond_to_msg(msg, "Unkown error updating repo: {}".format(repo_name))
                return

            if not gs.has_error():
                self._reload_repos(msg)

            self.respond_to_msg(msg, "{}: {}{}".format(repo_name, gs.stdout, gs.stderr))
예제 #2
0
    def update(self, msg, matches):
        repos = self._get_repos_from_config()

        if not repos:
            self.respond_to_msg(msg, "Warning: there are no repos in the configuration")
            return

        pkg_repo_dir = Path(PKG_REPO_DIR)
        if not pkg_repo_dir.exists():
            pkg_repo_dir.mkdir(parents=True)

        for repo_name, url in repos.items():
            gs = None
            if repo_name not in self._installed_repos():
                gs = git.clone(url, directory=repo_name, cwd=PKG_REPO_DIR)
            else:
                repo_path = self._repo_path(repo_name)
                git.reset(cwd=repo_path, hard=True)
                gs = git.pull(cwd=repo_path)

            if not gs:
                self.respond_to_msg(msg, "Unkown error updating repo: {}".format(repo_name))
                return

            if not gs.has_error():
                self._reload_repos(msg)

            self.respond_to_msg(msg, "{}: {}{}".format(repo_name, gs.stdout, gs.stderr))
예제 #3
0
파일: unittests.py 프로젝트: Thom7/telex
    def test_pull_up_to_date(self):
        with TemporaryDirectory() as d:
            # clone repo
            gs = git.clone(REPO_URL, cwd=d, directory=REPO_NAME)
            self.assertIsNotNone(gs)
            self.assertTrue(exists(join(d, REPO_NAME, ".git")))
            self.assertEqual(gs.exit_status, 0)

            # pull while on latest revision
            gs = git.pull(cwd=join(d, REPO_NAME))
            self.assertIsNotNone(gs)
            self.assertEqual(gs.exit_status, 0)
예제 #4
0
    def _upgrade_pkg(self, msg, pkg_name):
        pkg_path = Path(PKG_INSTALL_DIR) / pkg_name
        if not pkg_path.exists():
            self.respond_to_msg(msg, "Cannot upgrade \"{}\". Package does not appear to be installed.".format(pkg_name))

        gs = git.pull(str(pkg_path))

        pkg_req_path = Path(PKG_INSTALL_DIR) / pkg_name / "repository" / "requirements.txt"
        print('\n\n{}\n\n'.format(pkg_req_path))
        if pkg_req_path.exists():
            pip.main(['install', '--upgrade', '-r', str(pkg_req_path)])

        self.respond_to_msg(msg, "{} {}: {}{}".format(gs.exit_status, pkg_name, gs.stdout, gs.stderr))
예제 #5
0
    def _upgrade_pkg(self, msg, pkg_name):
        pkg_path = Path(PKG_INSTALL_DIR) / pkg_name
        if not pkg_path.exists():
            self.respond_to_msg(msg, "Cannot upgrade \"{}\". Package does not appear to be installed.".format(pkg_name))

        gs = git.pull(str(pkg_path))

        pkg_req_path = Path(PKG_INSTALL_DIR) / pkg_name / "repository" / "requirements.txt"
        print('\n\n{}\n\n'.format(pkg_req_path))
        if pkg_req_path.exists():
            pip.main(['install', '--upgrade', '-r', str(pkg_req_path)])

        self.respond_to_msg(msg, "{} {}: {}{}".format(gs.exit_status, pkg_name, gs.stdout, gs.stderr))
예제 #6
0
파일: unittests.py 프로젝트: Thom7/telex
    def test_pull_out_of_date(self):
        with TemporaryDirectory() as d:
            # Clone a repo
            gs = git.clone(REPO_URL, cwd=d, directory=REPO_NAME)
            self.assertIsNotNone(gs)
            self.assertEqual(gs.exit_status, 0)

            # Revert to the initial commit
            gs = git.reset(cwd=join(d, REPO_NAME), hard=True, commit="6f72f1ad1589f73d62165e19df873c59e829e1dd")
            self.assertIsNotNone(gs)
            self.assertEqual(gs.exit_status, 0)

            # Use pull to get update to the latest commit
            gs = git.pull(cwd=join(d, REPO_NAME))
            self.assertIsNotNone(gs)
            self.assertEqual(gs.exit_status, 0)