Skip to content

Commit

Permalink
Enhancement: add pull with rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Dec 9, 2017
1 parent 20aaf9b commit 4250110
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
"caption": "git: pull",
"command": "gs_pull"
},
{
"caption": "git: pull with rebase",
"command": "gs_pull",
"args": { "rebase": true }
},
{
"caption": "git: pull from branch",
"command": "gs_pull_from_branch"
Expand Down
13 changes: 8 additions & 5 deletions core/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ class GsPull(WindowCommand, GsPullBase):
Pull from remote tracking branch if it is found. Otherwise, use GsPullFromBranchCommand.
"""

def run(self):
def run(self, rebase=False):
self.rebase = rebase
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
rebase = self.rebase
if not rebase:
# honor the `pull.rebase` config implictly
pull_rebase = self.git("config", "pull.rebase", throw_on_stderr=False)
if pull_rebase and pull_rebase.strip() == "true":
rebase = True
upstream = self.get_upstream_for_active_branch()
if upstream:
remote, remote_branch = upstream.split("/", 1)
Expand Down
4 changes: 4 additions & 0 deletions docs/remotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Assuming you've recently fetched, this command allows you to create a local bran
This command will pull current branch from the tracking branch. If the tracking branch is not set, you will be prompted. If the git config `pull.rebase` is set true, the command will be execulated with `--rebase`.


## `git: pull with rebase`

Like `git: pull`, but rebasing on the remote branch explictly.

## `git: pull from branch`

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.
Expand Down

0 comments on commit 4250110

Please sign in to comment.