Skip to content

Commit

Permalink
Merge pull request #730 from randy3k/pullrebase
Browse files Browse the repository at this point in the history
Feature: add git pull with rebase command
  • Loading branch information
randy3k committed Aug 12, 2017
2 parents 4a4ec1c + a255762 commit ff66439
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
"caption": "git: pull",
"command": "gs_pull"
},
{
"caption": "git: pull with rebase",
"command": "gs_pull",
"args": { "rebase": true }
},
{
"caption": "git: push",
"command": "gs_push"
Expand Down
5 changes: 3 additions & 2 deletions core/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class GsPullCommand(WindowCommand, GitCommand):
Through a series of panels, allow the user to pull from a remote branch.
"""

def run(self, local_branch_name=None):
def run(self, local_branch_name=None, rebase=False):
self.local_branch_name = local_branch_name
self.rebase = rebase
sublime.set_timeout_async(self.run_async)

def run_async(self):
Expand Down Expand Up @@ -91,6 +92,6 @@ def do_pull(self, remote, branch, remote_branch):
Perform `git pull remote branch`.
"""
sublime.status_message("Starting pull...")
self.pull(remote=remote, branch=branch, remote_branch=remote_branch)
self.pull(remote=remote, branch=branch, remote_branch=remote_branch, rebase=self.rebase)
sublime.status_message("Pull complete.")
util.view.refresh_gitsavvy(self.window.active_view())
3 changes: 2 additions & 1 deletion core/git_mixins/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ def list_remote_branches(self, remote=None):
# Remove any duplicate branch names.
return [branch for idx, branch in enumerate(branches) if branches.index(branch) == idx]

def pull(self, remote=None, branch=None, remote_branch=None):
def pull(self, remote=None, branch=None, remote_branch=None, rebase=False):
"""
Pull from the specified remote and branch if provided, otherwise
perform default `git pull`.
"""
self.git(
"pull",
"--rebase" if rebase else None,
remote,
branch if not remote_branch else "{}:{}".format(remote_branch, branch)
)
Expand Down
4 changes: 4 additions & 0 deletions docs/remotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Assuming you've recently fetched, this command allows you to create a local bran

When running this command, you will be prompted first for the remote you want to pull from, and then the branch. If your local branch tracks a remote, that branch name will be pre-selected at the second prompt.

## `git: pull with rebase`

Like `git: pull`, but rebasing on the remote branch instead of merging.

**For the following commands you need to configure a username and password in git, so GitSavvy can use it.**

## `git: push`
Expand Down

0 comments on commit ff66439

Please sign in to comment.