Permalink
Browse files

Adding "pull/push current branch" commands

  • Loading branch information...
Can Yilmaz
Can Yilmaz committed Feb 10, 2012
1 parent 8ab5ebd commit e0f5bc3bd4c3b7cf7f1031ae1be5e2478d3461fd
Showing with 26 additions and 11 deletions.
  1. +8 −4 Default.sublime-commands
  2. +18 −7 git.py
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"
@@ -115,8 +123,4 @@
"caption": "Git: Add Selected Hunk",
"command": "git_add_selected_hunk"
}
- ,{
- "caption": "Git: Commit Selected Hunk",
- "command": "git_commit_selected_hunk"
- }
]
View
25 git.py
@@ -721,11 +721,29 @@ def run(self):
self.run_command(['git', 'pull'], callback=self.panel)
+class GitPullCurrentBranchCommand(GitWindowCommand):
+ def run(self):
+ self.run_command(['git', 'describe', '--contains', '--all', 'HEAD'], callback=self.pull_current_branch_done)
+
+ def pull_current_branch_done(self, result):
+ result = result.strip()
+ self.run_command(['git', 'pull', 'origin', result], callback=self.panel)
+
+
class GitPushCommand(GitWindowCommand):
def run(self):
self.run_command(['git', 'push'], callback=self.panel)
+class GitPushCurrentBranchCommand(GitWindowCommand):
+ def run(self):
+ self.run_command(['git', 'describe', '--contains', '--all', 'HEAD'], callback=self.push_current_branch_done)
+
+ def push_current_branch_done(self, result):
+ result = result.strip()
+ self.run_command(['git', 'push', 'origin', result], callback=self.panel)
+
+
class GitCustomCommand(GitTextCommand):
may_change_files = True
@@ -904,10 +922,3 @@ def cull_diff(self, result):
self.run_command(['git', 'apply', '--cached'], stdin=diffs)
else:
sublime.status_message("No selected hunk")
-
-
-class GitCommitSelectedHunk(GitAddSelectedHunkCommand):
- def run(self, edit):
- self.run_command(['git', 'diff', '--no-color', self.get_file_name()], self.cull_diff)
- self.get_window().run_command('git_commit')
-

0 comments on commit e0f5bc3

Please sign in to comment.