Example #1
0
class BumpIt:
    def __init__(self, configuration, dry_run, logger):
        self._folder_manager = FolderManager(folder=os.getcwd(),
                                             logger=logger,
                                             dry_run=dry_run)
        self._vcs = Git(
            dry_run=dry_run,
            settings=GitSettings(
                author=configuration.commit.author,
                apply_tag=configuration.tag.apply,
                tag_format=configuration.tag.format,
                auto_remote_push=configuration.auto_remote_push,
            ),
            logger=logger,
        )
        self._current_version = configuration.current_version
        self._tracked_files = configuration.tracked_files + [
            configuration.config_file
        ]
        self._base_branch = configuration.base_branch

    def execute(self, bumped_version):
        self._folder_manager.update(
            current_version=self._current_version,
            bumped_version=bumped_version,
            files=self._tracked_files,
        )

        self._vcs.update(
            current_version=self._current_version,
            bumped_version=bumped_version,
            base_branch=self._base_branch,
        )
Example #2
0
    def test_update_non_zero_exist_code(self):
        command_executor = CommandExecutorSpy(return_code=1)

        git = Git(
            dry_run=False,
            settings=self._settings,
            logger=self._logger_spy,
            command_executor=command_executor,
        )
        with pytest.raises(Exception):
            git.update(self._current_version, self._bumped_version,
                       self._base_branch)
Example #3
0
 def __init__(self, configuration, dry_run, logger):
     self._folder_manager = FolderManager(folder=os.getcwd(),
                                          logger=logger,
                                          dry_run=dry_run)
     self._vcs = Git(
         dry_run=dry_run,
         settings=GitSettings(
             author=configuration.commit.author,
             apply_tag=configuration.tag.apply,
             tag_format=configuration.tag.format,
             auto_remote_push=configuration.auto_remote_push,
         ),
         logger=logger,
     )
     self._current_version = configuration.current_version
     self._tracked_files = configuration.tracked_files + [
         configuration.config_file
     ]
Example #4
0
    def test_update_dry_run_tagging_disabled(self):
        git = Git(
            dry_run=True,
            settings=self._settings,
            logger=self._logger_spy,
            command_executor=self._command_executor,
        )
        git.update(self._current_version, self._bumped_version,
                   self._base_branch)

        assert self._command_executor.call_count == 0
        assert [
            "[DRY-RUN] Ran `git add .`",
            "[DRY-RUN] Ran `git commit --author 'A B <*****@*****.**>' "
            "-m 'Bumped version from 0.0.0 → 1.0.0.'`",
            "Skipped tagging...",
            "Skipped pushing changes to remote...",
        ] == self._logger_spy.messages
Example #5
0
    def test_invalid_tag_format(self):
        self._settings.tag_format = "invalid_format"

        with pytest.raises(ValueError):
            Git(
                dry_run=True,
                settings=self._settings,
                logger=self._logger_spy,
                command_executor=self._command_executor,
            )
Example #6
0
    def test_update_tagging_disabled(self):
        git = Git(
            dry_run=False,
            settings=self._settings,
            logger=self._logger_spy,
            command_executor=self._command_executor,
        )
        git.update(self._current_version, self._bumped_version,
                   self._base_branch)

        assert [
            "git add .",
            "git commit --author 'A B <*****@*****.**>' "
            "-m 'Bumped version from 0.0.0 → 1.0.0.'",
        ] == self._command_executor.commands
        assert [
            "[OK] git add .",
            "[OK] git commit --author 'A B <*****@*****.**>' "
            "-m 'Bumped version from 0.0.0 → 1.0.0.'",
            "Skipped tagging...",
            "Skipped pushing changes to remote...",
        ] == self._logger_spy.messages