Exemplo n.º 1
0
def main():
    " This method launches gitbuster."
    app = QApplication(sys.argv)

    if len(sys.argv) == 2 and is_top_git_directory(sys.argv[1]):
        filepath = os.path.abspath(sys.argv[1])
    else:
        filepath = select_git_directory()

    if not filepath:
        sys.exit(1)

    test_repo = Repo(filepath)
    if os.path.exists(os.path.join(filepath, ".git/rebase-merge")):
        # Special conflict mode
        os.chdir(filepath)
        orig_hexsha = open(".git/rebase-merge/head").read().strip()
        conflict_hexsha = open(".git/rebase-merge/stopped-sha").read().strip()
        unmerged_files = get_unmerged_files(conflict_hexsha, orig_hexsha,
                                            filepath)
        conflicts_dialog = ConflictsDialog(unmerged_files)
        ret = conflicts_dialog.exec_()
        if ret:
            solutions = conflicts_dialog.get_solutions()
            apply_solutions(solutions)
            print "Applied your solutions, you can now continue:"
            print "git rebase --continue"
        sys.exit()

    if test_repo.is_dirty():
        warning_title = "Unclean repository"
        warning_text = "The chosen repository has unstaged changes. " \
                       "You should commit or stash them. "\
                       "Do you want to continue anyway ?"
        warning_choice = QMessageBox.warning(None, warning_title,
                                             warning_text,
                                             "Yes",
                                             button1Text="No",
                                             button2Text ="Stash")

        if warning_choice == 1:
            sys.exit(2)
        elif warning_choice == 2:
            test_repo.git.stash()

    window = MainWindow(directory=filepath, debug=True)
    window.show()

    #reroute SIGINT to Qt.
    def quit(signum, frame):
        # Clean the repo : stages, tmp_rebase, remotes
        window._ui.actionQuit.trigger()
    signal.signal(signal.SIGINT, quit)

    #run app and exit with same code
    sys.exit(app.exec_())
Exemplo n.º 2
0
    def conflicts(self):
        """
            When the conflicts button is clicked, display the conflict details
            dialog.
        """
        model = self._clicked_commit.model()

        unmerged_files = model.get_unmerged_files()
        dialog = ConflictsDialog(unmerged_files, parent=self._parent)
        ret = dialog.exec_()

        if ret:
            solutions = dialog.get_solutions()
            model.set_conflict_solutions(solutions)

            # Applying with None will make the q_editable_model re-use the
            # previous parameters for log and force options.
            self._parent.apply_models([model,], None, None)