Skip to content

Commit

Permalink
Enhancement: use GsPullBase mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Dec 9, 2017
1 parent 014752b commit 20aaf9b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions core/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
from ..ui_mixins.quick_panel import show_branch_panel


class GsPull(WindowCommand, GitCommand):
class GsPullBase(GitCommand):

def do_pull(self, remote, remote_branch, rebase):
"""
Perform `git pull remote branch`.
"""
sublime.status_message("Starting pull...")
self.pull(remote=remote, remote_branch=remote_branch, rebase=rebase)
sublime.status_message("Pull complete.")
util.view.refresh_gitsavvy(self.window.active_view())


class GsPull(WindowCommand, GsPullBase):
"""
Pull from remote tracking branch if it is found. Otherwise, use GsPullFromBranchCommand.
"""
Expand All @@ -22,12 +34,12 @@ def run_async(self):
upstream = self.get_upstream_for_active_branch()
if upstream:
remote, remote_branch = upstream.split("/", 1)
self.pull(remote=remote, remote_branch=remote_branch, rebase=rebase)
self.do_pull(remote=remote, remote_branch=remote_branch, rebase=rebase)
else:
self.window.run_command("gs_pull_from_branch", {"rebase": rebase})


class GsPullFromBranchCommand(WindowCommand, GitCommand):
class GsPullFromBranchCommand(WindowCommand, GsPullBase):

"""
Through a series of panels, allow the user to pull from a remote branch.
Expand All @@ -49,13 +61,4 @@ def on_branch_selection(self, branch):
selected_remote, selected_remote_branch = branch.split("/", 1)

sublime.set_timeout_async(
lambda: self.do_pull(selected_remote, selected_remote_branch))

def do_pull(self, remote, remote_branch):
"""
Perform `git pull remote branch`.
"""
sublime.status_message("Starting pull...")
self.pull(remote=remote, remote_branch=remote_branch, rebase=self.rebase)
sublime.status_message("Pull complete.")
util.view.refresh_gitsavvy(self.window.active_view())
lambda: self.do_pull(selected_remote, selected_remote_branch, self.rebase))

0 comments on commit 20aaf9b

Please sign in to comment.