Example #1
0
    def test_changes_between(self):
        # Hashes from https://github.com/andresriancho/w3af/commits/threading2
        start = 'cb751e941bfa2063ebcef711642ed5d22ff9db87'
        end = '9c5f5614412dce67ac13411e1eebd754b4c6fb6a'

        changelog = ChangeLog(start, end)
        changes = changelog.get_changes()

        self.assertIsInstance(changes, list)
        self.assertEqual(len(changes), 4)

        self.assertIn(end, [commit.commit_id for commit in changes])

        last_commit = changes[-1]
        self.assertEqual(last_commit.summary,
                         'Minor improvement for ctrl+c handling.')
        self.assertEqual(last_commit.commit_id,
                         '98458d69d03d705d943969e68fc6930e5bbf55ca')
        self.assertEqual(last_commit.changes, [
            ('M', 'core/controllers/dependency_check/dependency_check.py'),
        ])

        first_commit = changes[0]
        self.assertEqual(
            first_commit.summary,
            'Removing pysvn fixes for pylint as they won\'t be used anymore')
        self.assertEqual(first_commit.commit_id,
                         '9c5f5614412dce67ac13411e1eebd754b4c6fb6a')
        self.assertEqual(
            first_commit.changes,
            [('D', 'core/controllers/tests/pylint_plugins/pysvn_fix.py'),
             ('M', 'core/controllers/tests/pylint.rc')])
    def test_not_added_new_dependencies(self):
        start = '479f30c95873c3e4f8370ceb91f8aeb74794d047'
        end = '87924241bf70c2321bc9f567e3d2ce62ee264fee'

        changelog = ChangeLog(start, end)

        self.assertFalse(self.vmgr._added_new_dependencies(changelog))
    def test_added_new_dependencies(self):
        start = 'cb751e941bfa2063ebcef711642ed5d22ff9db87'
        end = '9c5f5614412dce67ac13411e1eebd754b4c6fb6a'

        changelog = ChangeLog(start, end)

        self.assertTrue(self.vmgr._added_new_dependencies(changelog))
Example #4
0
    def test_str(self):
        # Hashes from https://github.com/andresriancho/w3af/commits/threading2
        start = 'cb751e941bfa2063ebcef711642ed5d22ff9db87'
        end = '9c5f5614412dce67ac13411e1eebd754b4c6fb6a'

        changelog = ChangeLog(start, end)
        changelog_str = str(changelog)

        self.assertTrue(
            changelog_str.startswith('9c5f561441: Removing pysvn fixes for'))
        self.assertIn('    D core/controllers/tests/pylint_', changelog_str)
        self.assertIn('    M core/controllers/tests/pylint.rc', changelog_str)
Example #5
0
 def test_changes_between(self):
     # Hashes from https://github.com/andresriancho/w3af/commits/threading2
     start = 'cb751e941bfa2063ebcef711642ed5d22ff9db87'
     end = '9c5f5614412dce67ac13411e1eebd754b4c6fb6a'
     
     changelog = ChangeLog(start, end)
     changes = changelog.get_changes()
     
     self.assertIsInstance(changes, list)
     self.assertEqual(len(changes), 4)
     
     self.assertIn(end, [commit.commit_id for commit in changes])
     
     last_commit = changes[-1]
     self.assertEqual(last_commit.summary, 'Minor improvement for ctrl+c handling.')
     self.assertEqual(last_commit.commit_id, '98458d69d03d705d943969e68fc6930e5bbf55ca')
     self.assertEqual(last_commit.changes, [('M', 'core/controllers/dependency_check/dependency_check.py'),])
     
     first_commit = changes[0]
     self.assertEqual(first_commit.summary, 'Removing pysvn fixes for pylint as they won\'t be used anymore')
     self.assertEqual(first_commit.commit_id, '9c5f5614412dce67ac13411e1eebd754b4c6fb6a')
     self.assertEqual(first_commit.changes, [('D', 'core/controllers/tests/pylint_plugins/pysvn_fix.py'),
                                             ('M', 'core/controllers/tests/pylint.rc')])
Example #6
0
    def pull(self):
        with self._actionlock:
            try:
                latest_before_pull = get_latest_commit()

                self._repo.remotes.origin.pull(progress=self._progress)

                after_pull = get_latest_commit()

            # The developers at the mailing list were unable to tell me
            # if the pull() would raise an exception on merge conflicts
            # or which exception would be raised. So I'm catching all and
            # verifying if there are conflicts in an exception and in the
            # case were no exceptions were raised
            except Exception as e:
                self.handle_conflicts(latest_before_pull)
                msg = self.UPD_ERROR_MSG + ' The original exception was: "%s"'
                raise GitClientError(msg % e)
            else:
                self.handle_conflicts(latest_before_pull)
                changelog = ChangeLog(latest_before_pull, after_pull)
                return changelog
Example #7
0
                self._repo.remotes.origin.pull(progress=self._progress)

                after_pull = get_latest_commit()

            # The developers at the mailing list were unable to tell me
            # if the pull() would raise an exception on merge conflicts
            # or which exception would be raised. So I'm catching all and
            # verifying if there are conflicts in an exception and in the
            # case were no exceptions were raised
            except Exception, e:
                self.handle_conflicts(latest_before_pull)
                msg = self.UPD_ERROR_MSG + ' The original exception was: "%s"'
                raise GitClientError(msg % e)
            else:
                self.handle_conflicts(latest_before_pull)
                changelog = ChangeLog(latest_before_pull, after_pull)
                return changelog

    # @retry(tries=2, delay=0.5, backoff=2)
    def fetch(self):
        with self._actionlock:
            try:
                self._repo.remotes.origin.fetch(progress=self._progress)
            except Exception:
                raise GitClientError(self.UPD_ERROR_MSG)

        return True

    def handle_conflicts(self, reset_commit_id):
        """
        This method verifies if the repository is in conflict and resolved it