def run(self, paths = []): for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = repo.repository object.command = ['git', 'checkout', 'master'] object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): if input == False: SideBarGit().prompt('Enter a commit message: ', '', self.run, paths) elif content != '': import sys content = (content[0].upper() + content[1:]).encode(sys.getfilesystemencoding()) for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): commitCommandAdd = ['git', 'add', '--'] commitCommandCommit = ['git', 'commit', '-m', content, '--'] for item in repo.items: commitCommandAdd.append(item.forCwdSystemPathRelativeFromRecursive(repo.repository.path())) commitCommandCommit.append(item.forCwdSystemPathRelativeFrom(repo.repository.path())) object = Object() object.item = repo.repository object.command = commitCommandAdd SideBarGit().run(object) object = Object() object.item = repo.repository object.to_status_bar = True object.command = commitCommandCommit SideBarGit().run(object) object = Object() object.item = repo.repository object.command = ['git','push'] SideBarGit().run(object, True)
def run(self, paths = []): for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = item.repository object.command = ['git','push','--tags'] object.to_status_bar = True SideBarGit().run(object, True)
def run(self, paths = []): for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): object = Object() object.item = item object.command = ['git', 'init'] object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = []): for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): commitCommand = ['git', 'commit', '--amend', '-C', 'HEAD', '--'] for item in repo.items: commitCommand.append(item.forCwdSystemPathRelativeFrom(repo.repository.path())) object = Object() object.item = repo.repository object.to_status_bar = True object.command = commitCommand SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): if input == False: SideBarGit().prompt('Push with options: ', "git push aRemoteName aLocalBranch:aRemoteBranch", self.run, paths) elif content != '': import sys for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = item.repository object.command = content.encode(sys.getfilesystemencoding()).split(' ') object.to_status_bar = True SideBarGit().run(object, True)
def on_done(self, extra, data, result): result = data[result].strip() if result.startswith("*"): return else: import sys branch = result.split(' ')[0] object = Object() object.item = extra object.command = ['git', 'branch', '-d', branch.encode(sys.getfilesystemencoding())] object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): if input == False: SideBarGit().prompt('New branch: ', "", self.run, paths) elif content != '': import sys content = content.encode(sys.getfilesystemencoding()) for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = repo.repository object.command = ['git', 'checkout', '-b', content] object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): if input == False: SideBarGit().prompt('Remote add: ', "git remote add aRemoteName "+sublime.get_clipboard(), self.run, paths) elif content != '': import sys content = content.encode(sys.getfilesystemencoding()) for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = repo.repository object.command = content.split(' ') object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): if input == False: SideBarGit().prompt('Enter a commit message: ', '', self.run, paths) elif content != '': import sys content = (content[0].upper() + content[1:]).encode(sys.getfilesystemencoding()) for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): object = Object() object.item = item.repository object.to_status_bar = True object.command = ['git', 'commit', '-a', '-m', content] SideBarGit().run(object)
def run(self, paths = [], confirm = False, drop_me = ''): if confirm == False: SideBarGit().confirm('Remove from repository, keep local copies? ', self.run, paths) else: for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()): command = ['git', 'rm', '-r', '--cached', '--'] for item in repo.items: command.append(item.forCwdSystemPathRelativeFrom(repo.repository.path())) object = Object() object.item = repo.repository object.command = command object.to_status_bar = True SideBarGit().run(object)
def run(self, paths = [], input = False, content = ''): failed = False if input == False: SideBarGit().prompt('Enter URL to clone: ', sublime.get_clipboard(), self.run, paths) elif content != '': import sys for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): object = Object() object.item = item object.command = ['git', 'clone', '--recursive', content.encode(sys.getfilesystemencoding())] object.to_status_bar = True if not SideBarGit().run(object, True): failed = True if not failed: SideBarGit().status('Cloned URL "'+content+'"')
def run( self, object, modal = False, background = False, refresh_funct_view = False, refresh_funct_command = False, refresh_funct_item = False, refresh_funct_to_status_bar = False, refresh_funct_title = False, refresh_funct_no_results = False, refresh_funct_syntax_file = False ): if not refresh_funct_view: pass else: object = Object() object.command = refresh_funct_command object.item = SideBarItem(refresh_funct_item, os.path.isdir(refresh_funct_item)) object.to_status_bar = refresh_funct_to_status_bar object.title = refresh_funct_title object.no_results = refresh_funct_no_results object.syntax_file = refresh_funct_syntax_file debug = False if debug: print '----------------------------------------------------------' print 'GIT:' print object.command print 'CWD:' print object.item.forCwdSystemPath() print 'PATH:' print object.item.forCwdSystemName() failed = False import sys if sys.platform == 'win32': object.command = map(self.escapeCMDWindows, object.command) cwd = object.item.forCwdSystemPath() try: if not modal : process = subprocess.Popen( object.command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell= sys.platform == 'win32', universal_newlines=True) else: if sys.platform == 'win32': process = subprocess.Popen( #" ".join(object.command), object.command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, universal_newlines=True) else: process = subprocess.Popen( object.command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False, universal_newlines=True) if background: if debug: print 'SUCCESS' print '----------------------------------------------------------' return True stdout, stderr = process.communicate() SideBarGit.last_stdout = str(stdout).rstrip() self.last_stdout = str(stdout).rstrip() stdout = stdout.strip() if stdout.find('fatal:') == 0 or stdout.find('error:') == 0 or stdout.find('Permission denied') == 0 or stderr: print 'FAILED' failed = True else: if debug: print 'SUCCESS' if stdout: if debug: print 'STDOUT' print stdout if stderr: print 'STDERR' print stderr except OSError as (errno, strerror): print 'FAILED' failed = True print errno print strerror SideBarGit.last_stdout = '' self.last_stdout = ''