示例#1
0
    def test_run(self):
        stash = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_stash_ref = MagicMock(return_value=stash)

        hist_command_runer = HistoryCommandRunner(git_data_getter, command_runner)
        hist_command_runer.run = MagicMock()
        stash_pop = StashPop(hist_command_runer, git_data_getter)
        stash_pop.run()

        hist_command_runer.run.assert_called_once_with(['git', 'stash', 'pop', stash])
示例#2
0
    def test_run(self):
        branch = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_name = MagicMock(return_value=branch)

        hist_command_runer = HistoryCommandRunner(git_data_getter, command_runner)
        hist_command_runer.run = MagicMock()
        merge_branch = MergeSquash(hist_command_runer, git_data_getter)
        merge_branch.run()

        hist_command_runer.run.assert_called_once_with(['git', 'merge', '--squash', branch])
    def test_run(self):
        hash = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_commit_hash = MagicMock(return_value=hash)

        hist_command_runer = HistoryCommandRunner(git_data_getter, command_runner)
        hist_command_runer.run_foreground = MagicMock()
        diff_commits = DiffCommits(hist_command_runer, git_data_getter)
        diff_commits.run()

        hist_command_runer.run_foreground.assert_called_once_with(['git', 'diff', hash, hash])
示例#4
0
    def test_run(self):
        hash = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_commit_hash = MagicMock(return_value=hash)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        reset = Reset(hist_command_runer, git_data_getter)
        reset.run()

        hist_command_runer.run.assert_called_once_with(['git', 'reset', hash])
示例#5
0
    def test_run(self):
        tag = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_tag_name = MagicMock(return_value=tag)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        merge_tag = MergeTag(hist_command_runer, git_data_getter)
        merge_tag.run()

        hist_command_runer.run.assert_called_once_with(['git', 'merge', tag])
    def test_run(self):
        branch = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_name = MagicMock(return_value=branch)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        checkout_branch = CheckoutBranch(hist_command_runer, git_data_getter)
        checkout_branch.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'checkout', branch])
示例#7
0
    def test_run(self):
        remote = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_remote_name = MagicMock(return_value=remote)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        fetch = Fetch(hist_command_runer, git_data_getter)
        fetch.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'fetch', remote])
示例#8
0
    def test_force_delete_no(self):
        branch = 'foo'
        branches = [branch]
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_names = MagicMock(return_value=branches)
        git_data_getter.get_confirm_force_delete = MagicMock(return_value="n")

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock(
            return_value="error: not fully merged")
        delete_branch = DeleteBranch(hist_command_runer, git_data_getter)
        delete_branch.run()
    def test_run(self):
        from_tag = 'v1.0.0'
        new_branch_name = 'newfoo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_tag_name = MagicMock(return_value=from_tag)
        git_data_getter.get_branch_name_from_input = MagicMock(return_value=new_branch_name)

        hist_command_runer = HistoryCommandRunner(git_data_getter, command_runner)
        hist_command_runer.run = MagicMock()
        branch_branch = BranchTag(hist_command_runer, git_data_getter)
        branch_branch.run()

        hist_command_runer.run.assert_called_once_with(['git', 'checkout', '-b', new_branch_name, from_tag])
示例#10
0
    def test_run(self):
        message = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_stash_message_from_input = MagicMock(
            return_value=message)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        stash_message = StashMessage(hist_command_runer, git_data_getter)
        stash_message.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'stash', 'push', '-m', message])
示例#11
0
    def test_run(self):
        branch = 'foo'
        branches = [branch]
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_names = MagicMock(return_value=branches)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        delete_branch = DeleteBranch(hist_command_runer, git_data_getter)
        delete_branch.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'branch', '-d', branch])
示例#12
0
    def test_run(self):
        tag = 'foo'
        tags = [tag]
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_tag_names = MagicMock(return_value=tags)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        delete_tag = DeleteTag(hist_command_runer, git_data_getter)
        delete_tag.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'tag', '-d', tag])
示例#13
0
    def test_run(self):
        tag = 'v1.0.0'
        remote = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_local_tag_name = MagicMock(return_value=tag)
        git_data_getter.get_remote_name = MagicMock(return_value=remote)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        fetch = PushTag(hist_command_runer, git_data_getter)
        fetch.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'push', '-u', remote, tag])
示例#14
0
    def test_run(self):
        branch = 'foo'
        hash = 'bash'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_name = MagicMock(return_value=branch)
        git_data_getter.get_commit_hash = MagicMock(return_value=hash)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        cherry_pick = CherryPick(hist_command_runer, git_data_getter)
        cherry_pick.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'cherry-pick', '-e', hash])
示例#15
0
    def test_run(self):
        remote = 'foo'
        tag = 'refs/tags/v1.0.0'
        tags = [tag]
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_remote_name = MagicMock(return_value=remote)
        git_data_getter.get_tag_names_remote = MagicMock(return_value=tags)

        hist_command_runer = HistoryCommandRunner(git_data_getter, command_runner)
        hist_command_runer.run = MagicMock()
        delete_tag_remote = DeleteTagRemote(hist_command_runer, git_data_getter)
        delete_tag_remote.run()

        calls = [call(['git', 'tag', '-d', tag]), call(['git', 'push', '--delete', remote, tag])]
        hist_command_runer.run.assert_has_calls(calls)
    def test_run(self):
        branch = 'bar'
        remote = 'foo'
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_current_branch_name = MagicMock(
            return_value=branch)
        git_data_getter.get_remote_name = MagicMock(return_value=remote)

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock()
        fetch = UpstreamPush(hist_command_runer, git_data_getter)
        fetch.run()

        hist_command_runer.run.assert_called_once_with(
            ['git', 'push', '-u', remote, branch])
示例#17
0
    def test_force_delete_yes(self):
        branch = 'foo'
        branches = [branch]
        command_runner = CommandRunner()
        git_data_getter = GitDataGetter(Fzf(), command_runner)
        git_data_getter.get_branch_names = MagicMock(return_value=branches)
        git_data_getter.get_confirm_force_delete = MagicMock(return_value="y")

        hist_command_runer = HistoryCommandRunner(git_data_getter,
                                                  command_runner)
        hist_command_runer.run = MagicMock(
            return_value="error: not fully merged")
        delete_branch = DeleteBranch(hist_command_runer, git_data_getter)
        delete_branch.run()

        calls = [
            call(['git', 'branch', '-d', branch]),
            call(['git', 'branch', '-D', branch])
        ]
        hist_command_runer.run.assert_has_calls(calls)
示例#18
0
 def __init__(self):
     command_runner = CommandRunner()
     self._fzf = Fzf()
     self._git_data_getter = GitDataGetter(self._fzf, command_runner)
     self._hist_command_runner = HistoryCommandRunner(
         self._git_data_getter, command_runner)