Beispiel #1
0
def currentBranchAsTag(ctx, branch_name=None, config_file='bumpr.rc'):
    # don't put at module level to avoid the requirements for other tasks
    from bumpr.config import Config
    from bumpr.releaser import Releaser
    import os

    if not branch_name:
        branch_name = os.environ.get('TRAVIS_BRANCH', None)
    if not branch_name:
        ret = ctx.run('git rev-parse --abbrev-ref HEAD | grep -v ^HEAD$ || '
                      'git rev-parse HEAD')
        if not ret.ok:
            raise RuntimeError("Can't get current branch")
        branch_name = ret.stdout.replace('\n', '')
    config = Config()
    config.override_from_config(config_file)
    releaser = Releaser(config)
    releaser.bump_files([(str(releaser.version), branch_name)])
Beispiel #2
0
    def test_override_hook_from_config(self):
        tested_hook = ReadTheDocHook
        bumprrc = '''\
        [{0}]
        bump = test
        '''.format(tested_hook.key)

        expected = deepcopy(DEFAULTS)
        for hook in HOOKS:
            if hook is tested_hook:
                expected[hook.key] = hook.defaults
                expected[hook.key]['bump'] = 'test'
            else:
                expected[hook.key] = False

        config = Config()
        with mock_ini(bumprrc) as mock:
            config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        self.assertDictEqual(config, expected)
Beispiel #3
0
    def test_override_hook_from_config(self):
        tested_hook = ReadTheDocHook
        bumprrc = '''\
        [{0}]
        bump = test
        '''.format(tested_hook.key)

        expected = deepcopy(DEFAULTS)
        for hook in HOOKS:
            if hook is tested_hook:
                expected[hook.key] = hook.defaults
                expected[hook.key]['bump'] = 'test'
            else:
                expected[hook.key] = False

        config = Config()
        with mock_ini(bumprrc) as mock:
            config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        self.assertDictEqual(config, expected)
Beispiel #4
0
    def test_override_from_config(self):
        bumprrc = '''\
        [bumpr]
        file = test.py
        files = README
        [bump]
        message = test
        '''

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        for hook in HOOKS:
            expected[hook.key] = False

        config = Config()
        with mock_ini(bumprrc) as mock:
            config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        self.assertDictEqual(config, expected)
Beispiel #5
0
    def test_override_from_config(self):
        bumprrc = '''\
        [bumpr]
        file = test.py
        files = README
        [bump]
        message = test
        '''

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['files'] = ['README']
        expected['bump']['message'] = 'test'
        for hook in HOOKS:
            expected[hook.key] = False

        config = Config()
        with mock_ini(bumprrc) as mock:
            config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        self.assertDictEqual(config, expected)
Beispiel #6
0
    def test_override_hook_from_config(self, mock_ini):
        tested_hook = ReadTheDocHook
        bumprrc = """\
        [{0}]
        bump = test
        """.format(
            tested_hook.key
        )

        expected = deepcopy(DEFAULTS)
        for hook in HOOKS:
            if hook is tested_hook:
                expected[hook.key] = hook.defaults
                expected[hook.key]["bump"] = "test"
            else:
                expected[hook.key] = False

        config = Config()
        mock = mock_ini(bumprrc)
        config.override_from_config("test.rc")

        mock.assert_called_once_with("test.rc")
        assert config == expected
Beispiel #7
0
    def test_override_from_config(self, mock_ini):
        bumprrc = '''\
        [bumpr]
        file = test.py
        files = README
        push = true
        [bump]
        message = test
        '''

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['files'] = ['README']
        expected['push'] = True
        expected['bump']['message'] = 'test'
        for hook in HOOKS:
            expected[hook.key] = False

        config = Config()
        mock = mock_ini(bumprrc)
        config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        assert config == expected
Beispiel #8
0
    def test_override_from_config(self, mock_ini):
        bumprrc = """\
        [bumpr]
        file = test.py
        files = README
        push = true
        [bump]
        message = test
        """

        expected = deepcopy(DEFAULTS)
        expected["file"] = "test.py"
        expected["files"] = ["README"]
        expected["push"] = True
        expected["bump"]["message"] = "test"
        for hook in HOOKS:
            expected[hook.key] = False

        config = Config()
        mock = mock_ini(bumprrc)
        config.override_from_config("test.rc")

        mock.assert_called_once_with("test.rc")
        assert config == expected
Beispiel #9
0
    def test_override_from_config(self, mock_ini):
        bumprrc = '''\
        [bumpr]
        file = test.py
        files = README
        push = true
        [bump]
        message = test
        '''

        expected = deepcopy(DEFAULTS)
        expected['file'] = 'test.py'
        expected['files'] = ['README']
        expected['push'] = True
        expected['bump']['message'] = 'test'
        for hook in HOOKS:
            expected[hook.key] = False

        config = Config()
        mock = mock_ini(bumprrc)
        config.override_from_config('test.rc')

        mock.assert_called_once_with('test.rc')
        assert config == expected