Exemplo n.º 1
0
    def _perform_do_branches(self, instance, branches, *args):
        '''If the branch name exists, try to checkout. If a new name, create
        the branch and checkout.
        If the code has modification, shows an alert and stops
        '''
        get_designer().close_popup()

        if self.repo.is_dirty():
            show_alert('Git checkout',
                       'Please, commit your changes before '
                       'switch branches.')
            return

        if not branches:
            return

        branch = branches[0]
        try:
            if branch in self.repo.heads:
                self.repo.heads[branch].checkout()
            else:
                self.repo.create_head(branch)
                self.repo.heads[branch].checkout()
            branch_name = self.repo.active_branch.name
            self.dispatch('on_branch', branch_name)
        except GitCommandError as e:
            show_alert('Git Branches', 'Failed to switch branch!\n' + str(e))
Exemplo n.º 2
0
    def do_add(self, *args):
        '''Git select files from a list to add
        '''
        d = get_designer()
        if d.popup:
            return False
        files = self.repo.untracked_files
        if not files:
            show_alert('Git Add', 'All files are already indexed by Git')
            return

        # create the popup
        fake_setting = FakeSettingList()
        fake_setting.allow_custom = False
        fake_setting.items = files
        fake_setting.desc = 'Select files to add to Git index'

        content = SettingListContent(setting=fake_setting)
        popup_width = min(0.95 * Window.width, 500)
        popup_height = min(0.95 * Window.height, 500)
        popup = Popup(
            content=content, title='Git - Add files', size_hint=(None, None),
            size=(popup_width, popup_height), auto_dismiss=False)

        content.bind(on_apply=self._perform_do_add,
                     on_cancel=d.close_popup)

        content.show_items()
        d.popup = popup
        popup.open()
Exemplo n.º 3
0
    def create_setup_py(self):
        '''Runs the GUI to create a setup.py file
        '''
        d = get_designer()
        if d.popup:
            return False
        proj_dir = get_current_project().path
        designer_content = self.designer.designer_content

        setup_path = os.path.join(proj_dir, 'setup.py')
        if os.path.exists(setup_path):
            show_alert('Create setup.py', 'setup.py already exists!')
            return False

        content = ToolSetupPy(path=setup_path)
        d.popup = Popup(title='Create setup.py', content=content,
                        size_hint=(None, None), size=(550, 350),
                        auto_dismiss=False)
        content.bind(on_cancel=d.close_popup)

        def on_create(*args):
            designer_content.update_tree_view(get_current_project())
            d.close_popup()

        content.bind(on_create=on_create)
        d.popup.open()
    def create_setup_py(self):
        '''Runs the GUI to create a setup.py file
        '''
        d = get_designer()
        if d.popup:
            return False
        proj_dir = get_current_project().path
        designer_content = self.designer.designer_content

        setup_path = os.path.join(proj_dir, 'setup.py')
        if os.path.exists(setup_path):
            show_alert('Create setup.py', 'setup.py already exists!')
            return False

        content = ToolSetupPy(path=setup_path)
        d.popup = Popup(title='Create setup.py',
                        content=content,
                        size_hint=(None, None),
                        size=(550, 350),
                        auto_dismiss=False)
        content.bind(on_cancel=d.close_popup)

        def on_create(*args):
            designer_content.update_tree_view(get_current_project())
            d.close_popup()

        content.bind(on_create=on_create)
        d.popup.open()
Exemplo n.º 5
0
    def create_setup_py(self):
        '''Runs the GUI to create a setup.py file
        '''
        proj_loader = self.designer.project_loader
        proj_dir = proj_loader.proj_dir
        designer_content = self.designer.designer_content

        setup_path = os.path.join(proj_dir, 'setup.py')
        if os.path.exists(setup_path):
            show_alert('Create setup.py', 'setup.py already exists!')
            return False

        content = ToolSetupPy(path=setup_path)
        self._popup = Popup(title='Create setup.py',
                            content=content,
                            size_hint=(None, None),
                            size=(550, 400),
                            auto_dismiss=False)
        content.bind(on_cancel=self._popup.dismiss)

        def on_create(*args):
            designer_content.update_tree_view(proj_loader)
            self._popup.dismiss()

        content.bind(on_create=on_create)
        self._popup.open()
Exemplo n.º 6
0
 def _perform_do_add(self, instance, selected_files, *args):
     '''Add the selected files to git index
     '''
     try:
         self.repo.index.add(selected_files)
         show_message('%d file(s) added to Git index' %
                      len(selected_files), 5, 'info')
         get_designer().close_popup()
     except GitCommandError as e:
         show_alert('Git Add', 'Failed to add files to Git!\n' + str(e))
Exemplo n.º 7
0
 def do_init(self, *args):
     '''Git init
     '''
     try:
         self.repo = Repo.init(self.path, mkdir=False)
         self.repo.index.commit('Init commit')
         self.is_repo = True
         self._update_menu()
         show_message('Git repo initialized', 5, 'info')
     except:
         show_alert('Git Init', 'Failted to initialize repo!')
Exemplo n.º 8
0
 def _perform_do_commit(self, input, *args):
     '''Perform the git commit with data from InputDialog
     '''
     message = input.get_user_input()
     if self.repo.is_dirty():
         try:
             self.repo.git.commit('-am', message)
             show_message('Commit: ' + message, 5, 'info')
         except GitCommandError as e:
             show_alert('Git Commit', 'Failed to commit!\n' + str(e))
     else:
         show_alert('Git Commit', 'There is nothing to commit')
     self._popup.dismiss()
Exemplo n.º 9
0
 def _perform_do_commit(self, input, *args):
     '''Perform the git commit with data from InputDialog
     '''
     message = input.get_user_input()
     if self.repo.is_dirty():
         try:
             self.repo.git.commit('-am', message)
             show_message('Commit: ' + message, 5, 'info')
         except GitCommandError as e:
             show_alert('Git Commit', 'Failed to commit!\n' + str(e))
     else:
         show_alert('Git Commit', 'There is nothing to commit')
     self._popup.dismiss()
Exemplo n.º 10
0
    def create_gitignore(self):
        '''Create .gitignore
        '''
        proj_dir = get_current_project().path
        status = self.designer.statusbar

        gitignore_path = os.path.join(proj_dir, '.gitignore')

        if os.path.exists(gitignore_path):
            show_alert('Create .gitignore', '.gitignore already exists!')
            return False

        gitignore = '''*.pyc
*.pyo
bin/
.designer/
.buildozer/
__pycache__/'''

        f = open(gitignore_path, 'w').write(gitignore)
        status.show_message('.gitignore created successfully', 5, 'info')
    def create_gitignore(self):
        '''Create .gitignore
        '''
        proj_dir = get_current_project().path
        status = self.designer.statusbar

        gitignore_path = os.path.join(proj_dir, '.gitignore')

        if os.path.exists(gitignore_path):
            show_alert('Create .gitignore', '.gitignore already exists!')
            return False

        gitignore = '''*.pyc
*.pyo
bin/
.designer/
.buildozer/
__pycache__/'''

        f = open(gitignore_path, 'w').write(gitignore)
        status.show_message('.gitignore created successfully', 5, 'info')
Exemplo n.º 12
0
    def do_pull(self, *args):
        '''Open a list of remotes to pull remote data.
        If there is not remote, shows an alert
        '''
        d = get_designer()
        if d.popup:
            return False
        if not self.validate_remote():
            show_alert('Git - Remote Authentication',
                       'To use Git remote you need to enter your ssh password')
            return
        remotes = []
        for r in self.repo.remotes:
            remotes.append(r.name)
        if not remotes:
            show_alert('Git Pull Remote', 'There is no git remote configured!')
            return

        # create the popup
        fake_setting = FakeSettingList()
        fake_setting.allow_custom = False
        fake_setting.items = remotes
        fake_setting.desc = 'Pull data from the selected remote'
        fake_setting.group = 'git_remote'

        content = SettingListContent(setting=fake_setting)
        popup_width = min(0.95 * Window.width, 500)
        popup_height = min(0.95 * Window.height, 500)
        popup = popup = Popup(
            content=content, title='Git - Pull Remote', size_hint=(None, None),
            size=(popup_width, popup_height), auto_dismiss=False)

        content.bind(on_apply=self._perform_do_pull,
                     on_cancel=d.close_popup)

        content.selected_items = [remotes[0]]
        content.show_items()
        d.popup = popup
        popup.open()
Exemplo n.º 13
0
    def create_setup_py(self):
        '''Runs the GUI to create a setup.py file
        '''
        proj_loader = self.designer.project_loader
        proj_dir = proj_loader.proj_dir
        designer_content = self.designer.designer_content

        setup_path = os.path.join(proj_dir, 'setup.py')
        if os.path.exists(setup_path):
            show_alert('Create setup.py', 'setup.py already exists!')
            return False

        content = ToolSetupPy(path=setup_path)
        self._popup = Popup(title='Create setup.py', content=content,
                            size_hint=(None, None), size=(550, 400),
                            auto_dismiss=False)
        content.bind(on_cancel=self._popup.dismiss)

        def on_create(*args):
            designer_content.update_tree_view(proj_loader)
            self._popup.dismiss()

        content.bind(on_create=on_create)
        self._popup.open()
Exemplo n.º 14
0
 def on_codeinput_theme(self, section, key, value, *args):
     if not value in styles.get_all_styles():
         show_alert("Error", "This theme is not available")
     else:
         self.style_name = value
Exemplo n.º 15
0
 def on_codeinput_theme(self, section, key, value, *args):
     if not value in styles.get_all_styles():
         show_alert("Error", "This theme is not available")
     else:
         self.style_name = value