Skip to content

Commit

Permalink
Enhancement: offer push to remote rather than configuring remote
Browse files Browse the repository at this point in the history
  • Loading branch information
randy3k committed Aug 15, 2017
1 parent 0aff3d7 commit 63a5105
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions github/commands/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
from .. import git_mixins
from ...common import interwebs
from ...common import util
from ...core.commands.push import GsPushToBranchNameCommand

SET_UPSTREAM_PROMPT = ("You have not set an upstream for the active branch. "
"Would you like to set one?")

PUSH_PROMPT = ("You have not set an upstream for the active branch. "
"Would you like to push to a remote?")


class GsPullRequestCommand(TextCommand, GitCommand, git_mixins.GithubRemotesMixin):
Expand Down Expand Up @@ -155,19 +157,14 @@ def run(self, edit):
sublime.set_timeout_async(self.run_async, 0)

def run_async(self):
savvy_settings = sublime.load_settings("GitSavvy.sublime-settings")
if savvy_settings.get("prompt_for_tracking_branch") and not self.get_upstream_for_active_branch():
if sublime.ok_cancel_dialog(SET_UPSTREAM_PROMPT):
self.remotes = list(self.get_remotes().keys())

if not self.remotes:
self.view.window().show_quick_panel(["There are no remotes available."], None)
else:
self.view.window().show_quick_panel(
self.remotes,
self.on_select_remote,
flags=sublime.MONOSPACE_FONT
)
if not self.get_upstream_for_active_branch():
if sublime.ok_cancel_dialog(PUSH_PROMPT):
self.view.window().run_command(
"gs_push_and_create_pull_request",
{
"branch_name": self.get_current_branch_name(),
"set_upstream": True
})

else:
remote_branch = self.get_active_remote_branch()
Expand Down Expand Up @@ -242,3 +239,10 @@ def on_select_branch(self, branch_index):
self.git("branch", "-u", remote_ref, self.current_local_branch)

sublime.set_timeout_async(self.run_async, 0)


class GsPushAndCreatePullRequestCommand(GsPushToBranchNameCommand):

def do_push(self, *args, **kwargs):
super().do_push(*args, **kwargs)
self.window.view.run_command("gs_create_pull_request")

0 comments on commit 63a5105

Please sign in to comment.