Skip to content

Commit

Permalink
Adding "pull/push current branch" commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Yilmaz committed Feb 10, 2012
1 parent 8ab5ebd commit e0f5bc3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
12 changes: 8 additions & 4 deletions Default.sublime-commands
Expand Up @@ -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"
Expand Down Expand Up @@ -115,8 +123,4 @@
"caption": "Git: Add Selected Hunk",
"command": "git_add_selected_hunk"
}
,{
"caption": "Git: Commit Selected Hunk",
"command": "git_commit_selected_hunk"
}
]
25 changes: 18 additions & 7 deletions git.py
Expand Up @@ -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

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