# Patchpal

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Version](https://img.shields.io/badge/version-0.8.0-orange.svg)]()

Patchpal is an AI-assisted cherry-picking and merge conflict resolution application that
simplifies the process of applying fixes and features across different code bases. It helps
with such tasks as backporting commits from newer software versions to older stable releases,
recovering after git rebase, working with git stash, etc. It provides intelligent conflict
resolution, automatic dependency detection, and advanced patch application algorithms to
handle complex cherry-picking scenarios.

## Table of Contents

- [Usage](#usage)
- [Features](#features)
- [Install](#install)
- [Build](#build-it-yourself)
- [Release Notes](#release-notes)
- [License](#license)

## Usage

See the [User guide](Usage.md).

## Features

- **AI-Assisted Conflict Resolution**: Intelligent suggestions for resolving merge conflicts
- **Multi-Commit Support**: Process multiple commits in a single session with navigation, reordering, and dependency management
- **Dependency Detection**: Automatically identifies missing prerequisite patches and offers to add them
- **Advanced Patch Application**: Sophisticated algorithm that accurately locates where hunks should be applied
- **File Operation Support**: Handles patches that add, delete, and rename files
- **Flexible File Matching**: Automatically handles filename differences between upstream and downstream
- **Git Integration**: Works seamlessly with git for resolving merge conflicts after a git merge, rebase, cherry-pick and stash operations
- **Multi-Language Support**: Supports C/C++, Go, Rust, Python, Java, JavaScript and most other languages
- **Keyboard Navigation**: Extensive keyboard shortcuts for efficient navigation between hunks and commits
- **Fast Forward**: Auto-accept clean hunks and fast-forward through commits to speed up the workflow
- **JIRA Integration**: Automatically adds JIRA issue references to commit messages
- **CLI Interface**: Non-interactive command-line frontend for scripting and automation

## Install

### Fedora packages

The official Fedora packages are available from Copr:
https://copr.fedorainfracloud.org/coprs/jbenc/patchpal/

### Build it yourself

If you don't have Fedora or want to follow the development:

```
dnf install cargo clang-devel gtk4-devel
git clone https://gitlab.com/patchpal-ai/patchpal-gui
cd patchpal-gui
cargo build --release
```

## Release Notes

### V0.8.0
- **Multi-commit support**: Apply multiple commits in a single session. Navigate between commits, manage the commit list with reordering, sorting, and the ability to add missing dependencies directly.
- **CLI interface**: New non-interactive command-line frontend for scripting and automation.
- **Fast forward**: Auto-accept clean hunks and fast-forward through remaining commits.
- **Internal refactoring**: Significant rearchitecting of the codebase to cleanly separate algorithms, UI logic, and presentation. Please report any regressions.

### V0.7.0
- **Undo**: Per-hunk undo functionality for easier mistake recovery.
- **Commit details**: Display detailed commit information, including the commit message. This also works for merge conflict resolution during git rebase and git cherry-pick.
- **Performance improvements**: Parallelized patch application for faster processing of commits with many files.
- **Improved keyboard navigation**: Added keyboard shortcuts for displaying the shortcut list and commit descriptions.

### V0.6.0
- **New merge conflict resolution mode**: Running Patchpal without arguments allows easy resolution of an ongoing merge conflict.
- **Easier use**: Jumping over hunks attempts to show the full hunk. Clean hunks are now approved automatically in mergetool mode.
- **Bug fixes**: Fixed reporting already backported commits as missing. Fixed focus issues.

### V0.5.0
- **Improved documentation**: Updated the README and added a user guide.
- **Telemetry**: Report anonymous metrics. It's an opt-in.
- **Bugfixes**: mergetool works again.

### V0.4.0
- **Dependency detection**: When something doesn't apply cleanly, Patchpal will show you which patches you're missing. Currently, you can view the missing patches and copy the commit ids.
- **Significantly improved algorithm for patch application**: Patchpal now pinpoints the correct location for each hunk much more reliably.
- **Patches that add, delete and rename files are now supported**.
- **Filename deviations are handled gracefully**: Different upstream and downstream file names are automatically recognized. If you apply a patch that changes a file with a different name downstream, it will just work.
- **Improved navigation**: Navigation to the next/previous unapproved hunk is now possible, including keyboard navigation.
- **Faster AI results and suggestions**: The AI backend moved to a faster server.
- **Support for multiple languages**: We now officially support non-kernel use cases and different languages, including Go, Rust and Python.
- **Numerous bugfixes**.

## License

Patchpal is licensed under the Apache License 2.0. See the [LICENSE.md](LICENSE.md) file for details.
