Skip to content

Commit

Permalink
Enhancement: git pull from remote tracking branch directly
Browse files Browse the repository at this point in the history
and the original `git: pull` command is renamed as `git: pull from branch`.
  • Loading branch information
randy3k committed Dec 9, 2017
1 parent 633dea9 commit 1a902e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@
"command": "gs_pull"
},
{
"caption": "git: pull with rebase",
"command": "gs_pull",
"caption": "git: pull from branch",
"command": "gs_pull_from_branch"
},
{
"caption": "git: pull from branch with rebase",
"command": "gs_pull_from_branch",
"args": { "rebase": true }
},
{
Expand Down
23 changes: 22 additions & 1 deletion core/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,28 @@
from ..ui_mixins.quick_panel import show_branch_panel


class GsPullCommand(WindowCommand, GitCommand):
class GsPull(WindowCommand, GitCommand):
"""
Pull from remote tracking branch if it is found. Otherwise, use GsPullFromBranchCommand.
"""

def run(self):
sublime.set_timeout_async(self.run_async)

def run_async(self):
# honor the `pull.rebase` config implictly
rebase = self.git("config", "pull.rebase", throw_on_stderr=False) or False
if rebase and rebase.strip() == "true":
rebase = True
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)
else:
self.window.run_command("gs_pull_from_branch", {"rebase": rebase})


class GsPullFromBranchCommand(WindowCommand, GitCommand):

"""
Through a series of panels, allow the user to pull from a remote branch.
Expand Down

0 comments on commit 1a902e9

Please sign in to comment.