Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding "Pull/Push Current Branch" commands #88

Merged
merged 7 commits into from Apr 8, 2012
View
@@ -1,3 +1,4 @@
*.pyc
*.tmLanguage.cache
+.DS_Store
package-metadata.json
View
@@ -83,10 +83,18 @@
"caption": "Git: Pull",
"command": "git_pull"
}
+ ,{
+ "caption": "Git: Pull Current Branch",
+ "command": "git_pull_current_branch"
+ }
,{
"caption": "Git: Push",
"command": "git_push"
}
+ ,{
+ "caption": "Git: Push Current Branch",
+ "command": "git_push_current_branch"
+ }
,{
"caption": "Git: Show Current File",
"command": "git_show"
View
29 git.py
@@ -721,11 +721,40 @@ def run(self):
self.run_command(['git', 'pull'], callback=self.panel)
+class GitPullCurrentBranchCommand(GitWindowCommand):
+ command_to_run_after_describe = 'pull'
+
+ def run(self):
+ self.run_command(['git', 'describe', '--contains', '--all', 'HEAD'], callback=self.describe_done)
+
+ def describe_done(self, result):
+ self.current_branch = result.strip()
+ self.run_command(['git', 'remote'], callback=self.remote_done)
+
+ def remote_done(self, result):
+ self.remotes = result.rstrip().split('\n')
+ if len(self.remotes) == 1:
+ self.panel_done()
+ else:
+ self.quick_panel(self.remotes, self.panel_done, sublime.MONOSPACE_FONT)
+
+ def panel_done(self, picked=0):
+ if picked < 0 or picked >= len(self.remotes):
+ return
+ self.picked_remote = self.remotes[picked]
+ self.picked_remote = self.picked_remote.strip()
+ self.run_command(['git', self.command_to_run_after_describe, self.picked_remote, self.current_branch])
+
+
class GitPushCommand(GitWindowCommand):
def run(self):
self.run_command(['git', 'push'], callback=self.panel)
+class GitPushCurrentBranchCommand(GitPullCurrentBranchCommand):
+ command_to_run_after_describe = 'push'
+
+
class GitCustomCommand(GitTextCommand):
may_change_files = True