Ejemplo n.º 1
0
    def _generate_issue_folder_path(id):
        dir = Path.cwd()

        gm = GitManager()
        if dir.parts[-1] != "issue" and gm.is_worktree():
            dir = dir.joinpath("issue")

        return dir.joinpath(id)
Ejemplo n.º 2
0
    def merge(self, merger):
        print("Beginning merge process")
        conflicts = merger.parse_unmerged_conflicts()
        create_resolver = merger.produce_create_resolver(conflicts)
        create_resolution = create_resolver.generate_resolution()
        create_resolution.resolve()

        tracker = create_resolution.tracker if create_resolution.tracker.issue_count != 0 else Tracker.obtain_tracker(
        )

        divergence_resolver = merger.produce_create_edit_divergence_resolver(
            conflicts, create_resolution.resolved_issues, tracker)
        divergence_resolution = divergence_resolver.generate_resolution()
        divergence_resolution.resolve()

        comment_resolvers = merger.produce_comment_index_resolvers(conflicts)
        for resolver in comment_resolvers:
            resolution = resolver.generate_resolution()
            resolution.resolve()

        manual_conflicts = merger.filter_manual_conflicts(conflicts)

        if manual_conflicts == []:
            self.repo.git.commit("-m", "merge conflict resolution")
            print("Merge successful. All files have been merged.")
        else:
            print(
                "I wasn't able to resolve all the conflicts. This typically happens when something's been edited "
                "in both the remote and current repository.")
            print("Here are the files I couldn't resolve:")

            for conflict in manual_conflicts:
                print(f"\t{conflict.path}")

            gm = GitManager()
            if gm.is_worktree():
                print(
                    "Exiting program to prevent branch unloading. This would cause loss of resolved conflicts."
                )
                exit()