Esempio n. 1
0
    def test_update_results(self):
        """
        If we have two plugins that are updated.
        """
        plugins_dir = join(self.gitrepodir, '.jig', 'plugins')
        fake_cloned_plugin = join(plugins_dir, 'abcdef1234567890')

        makedirs(fake_cloned_plugin)

        create_plugin(fake_cloned_plugin, bundle='a', name='a')
        create_plugin(fake_cloned_plugin, bundle='b', name='b')

        with patch.object(Git, 'execute'):
            # Fake the git pull command
            mock_execute = Git.execute

            Git.execute.return_value = (0, 'Already up to date.', '')

            results = update_plugins(self.gitrepodir)

        pm, value = results.items()[0]

        # We have our two plugins from the manager
        self.assertEquals(2, len(pm.plugins))

        # And it called ``git pull`` on the repository
        mock_execute.assert_called_once_with(
            ['git', 'pull'], with_extended_output=True)
Esempio n. 2
0
    def update(self, argv):
        """
        Updates any plugins installed through a URL.

        This basically runs ``git pull`` within any directory inside the
        :file:`.jig/plugis` directory. It's a very simple method of updating
        plugins that have already been installed.
        """
        path = argv.path

        with self.out() as out:
            # Make sure that this directory has been initialized for Jig
            get_jigconfig(path)

            results = update_plugins(path)

            if not results:
                out.append('No plugins to update.')
                return

            out.append('Updating plugins')
            out.append('')

            for pm, output in results.items():
                names = set([i.name for i in pm.plugins])
                bundles = set([i.bundle for i in pm.plugins])

                out.append('Plugin {0} in bundle {1}'.format(
                    ', '.join(names), ', '.join(bundles)))
                out.extend(indent(output.splitlines()))
Esempio n. 3
0
    def update_plugins(self, gitrepo):
        """
        Prompt the user to update the plugins if available.

        :params string gitrepo: path to the Git repository
        """
        with self.view.out() as out:
            out.append(u'Checking for plugin updates\u2026')

        # Examine the remotes of the installed plugins
        if not plugins_have_updates(gitrepo):
            # If we don't have updates, change the date forward for the next
            # check to be a few days from now.
            set_jigconfig(gitrepo, set_checked_for_updates(gitrepo))
            # No updates, so nothing else we need to do
            return False

        # We have updates, ask the user if they want to fetch from the
        # remote and install them
        while True:
            try:
                answer = raw_input(
                    '\nPlugin updates are available, install ("y"/"n"): ')
            except KeyboardInterrupt:
                # If the user CTRL-C's out, leave the last date checked for
                # updates alone. Their intention with this is not really a
                # yes or a now so play it safe.
                return False
            else:
                # No KeyboardInterrupt, this is good enough to go ahead and
                # move the date we checked for updates to "now".
                set_jigconfig(gitrepo, set_checked_for_updates(gitrepo))
                # We now have a possible answer, do the appropriate thing
                if answer and answer[0].lower() == 'y':
                    update_plugins(gitrepo)
                    return True
                if answer and answer[0].lower() == 'n':
                    return False
Esempio n. 4
0
File: runner.py Progetto: dmore/jig
    def update_plugins(self, gitrepo):
        """
        Prompt the user to update the plugins if available.

        :params string gitrepo: path to the Git repository
        """
        with self.view.out() as out:
            out.append(u'Checking for plugin updates\u2026')

        # Examine the remotes of the installed plugins
        if not plugins_have_updates(gitrepo):
            # If we don't have updates, change the date forward for the next
            # check to be a few days from now.
            set_jigconfig(gitrepo, set_checked_for_updates(gitrepo))
            # No updates, so nothing else we need to do
            return False

        # We have updates, ask the user if they want to fetch from the
        # remote and install them
        while True:
            try:
                answer = raw_input(
                    '\nPlugin updates are available, install ("y"/"n"): ')
            except KeyboardInterrupt:
                # If the user CTRL-C's out, leave the last date checked for
                # updates alone. Their intention with this is not really a
                # yes or a now so play it safe.
                return False
            else:
                # No KeyboardInterrupt, this is good enough to go ahead and
                # move the date we checked for updates to "now".
                set_jigconfig(gitrepo, set_checked_for_updates(gitrepo))
                # We now have a possible answer, do the appropriate thing
                if answer and answer[0].lower() == 'y':
                    update_plugins(gitrepo)
                    return True
                if answer and answer[0].lower() == 'n':
                    return False
Esempio n. 5
0
 def test_update_empty_result(self):
     """
     If no plugins are installed, results are empty
     """
     # None are installed so we get an empty list
     self.assertEqual({}, update_plugins(self.gitrepodir))