Пример #1
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(
                ""
                "Please supply a commit message.\n\n"
                "A good commit message has the following format:\n\n"
                "- First line: Describe in one sentence what you did.\n"
                "- Second line: Blank\n"
                "- Remaining lines: Describe why this change is good.\n"
            )
            Interaction.log(error_msg)
            Interaction.information(N_("Missing Commit Message"), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_("" "No changes to commit.\n\n" "You must stage at least 1 file before you can commit.")
            if self.model.modified:
                informative_text = N_("Would you like to stage and " "commit all modified files?")
                if not qtutils.confirm(
                    N_("Stage and commit?"),
                    error_msg,
                    informative_text,
                    N_("Stage and Commit"),
                    default=True,
                    icon=qtutils.save_icon(),
                ):
                    return
            else:
                Interaction.information(N_("Nothing to commit"), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (
            amend
            and self.model.is_commit_published()
            and not qtutils.confirm(
                N_("Rewrite Published Commit?"),
                N_(
                    "This commit has already been published.\n"
                    "This operation will rewrite published history.\n"
                    "You probably don't want to do this."
                ),
                N_("Amend the published commit?"),
                N_("Amend Commit"),
                default=False,
                icon=qtutils.save_icon(),
            )
        ):
            return
        no_verify = self.bypass_commit_hooks_action.isChecked()
        sign = self.sign_action.isChecked()
        status, out, err = cmds.do(cmds.Commit, amend, msg, sign, no_verify=no_verify)
        if status != 0:
            Interaction.critical(N_("Commit failed"), N_('"git commit" returned exit code %s') % (status,), out + err)
Пример #2
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            Interaction.log(error_msg)
            Interaction.information(N_('Missing Commit Message'), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_(
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = N_('Would you like to stage and '
                                      'commit all modified files?')
                if not qtutils.confirm(N_('Stage and commit?'),
                                       error_msg,
                                       informative_text,
                                       N_('Stage and Commit'),
                                       default=True,
                                       icon=icons.save()):
                    return
            else:
                Interaction.information(N_('Nothing to commit'), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and not qtutils.confirm(
                N_('Rewrite Published Commit?'),
                N_('This commit has already been published.\n'
                   'This operation will rewrite published history.\n'
                   'You probably don\'t want to do this.'),
                N_('Amend the published commit?'),
                N_('Amend Commit'),
                default=False,
                icon=icons.save())):
            return
        no_verify = self.bypass_commit_hooks_action.isChecked()
        sign = self.sign_action.isChecked()
        status, out, err = cmds.do(cmds.Commit,
                                   amend,
                                   msg,
                                   sign,
                                   no_verify=no_verify)
        if status != 0:
            Interaction.critical(
                N_('Commit failed'),
                N_('"git commit" returned exit code %s') % (status, ),
                out + err)
Пример #3
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            Interaction.log(error_msg)
            Interaction.information(N_('Missing Commit Message'), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_(''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = N_('Would you like to stage and '
                                      'commit all modified files?')
                if not confirm(N_('Stage and commit?'),
                               error_msg,
                               informative_text,
                               N_('Stage and Commit'),
                               default=False,
                               icon=save_icon()):
                    return
            else:
                Interaction.information(N_('Nothing to commit'), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
            not confirm(N_('Rewrite Published Commit?'),
                        N_('This commit has already been published.\n'
                           'This operation will rewrite published history.\n'
                           'You probably don\'t want to do this.'),
                        N_('Amend the published commit?'),
                        N_('Amend Commit'),
                        default=False, icon=save_icon())):
            return
        status, output = cmds.do(cmds.Commit, amend, msg)
        if status != 0:
            Interaction.critical(N_('Commit failed'),
                                 N_('"git commit" returned exit code %s') %
                                    (status,),
                                 output)
Пример #4
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = tr(
                ''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            Interaction.log(error_msg)
            Interaction.information('Missing Commit Message', error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = tr(
                ''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = tr('Would you like to stage and '
                                      'commit all modified files?')
                if not confirm('Stage and commit?',
                               error_msg,
                               informative_text,
                               'Stage and Commit',
                               default=False,
                               icon=save_icon()):
                    return
            else:
                Interaction.information('Nothing to commit', error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
                not confirm('Rewrite Published Commit?',
                            'This commit has already been published.\n'
                            'This operation will rewrite published history.\n'
                            'You probably don\'t want to do this.',
                            'Amend the published commit?',
                            'Amend Commit',
                            default=False,
                            icon=save_icon())):
            return
        cmds.do(cmds.Commit, amend, msg)