This website allows you to view public GitHub pull requests using a semantic/structural diff. Just enter the URL of the pull request your are interested in and you will get a diff that hides changes to the code style as well as other irrelevant modifications.
The pull request viewer is mostly a prototype to see how difficult it would be to port our VS Code extension SemanticDiff to the web. It might therefore lack some features or contain bugs. Feel free to open an issue if you find any. If there is enough interest we might develop it into a full GitHub app.
Check out the other questions for more details.
The pull request viewer currently supports the following programming languages and data exchange formats:
Your language is not included? Feel free to open a feature request in our issue tracker.
Our diff is able to detect moved or copied blocks of code, as well as renaming of variables, functions, and classes. Additional types of refactorings will be added over time. If you have suggestions on what should be recognized, feel free to open a feature request in our issue tracker.
Please note that our technology is currently in beta state and some features might still be work in progress.
Yes, we offer an extension for Visual Studio Code called SemanticDiff.
This pull request viewer is actually based on our VS Code extension and shares a lot of the code. The extension is not specific to GitHub and can be used with all diffs displayed by VS Code (as long as the programming language is supported). If you want view GitHub PRs without checking them out locally, you will also need to install the GitHub Pull Requests and Issues extension.
Common diffs treat source code as text files, and generate a visualization based on a simple line-by-line comparison. This is far from perfect: There are many types of code changes, such as inserting line breaks between function arguments, that don't have any effect on the software but are displayed as changes. This adds a lot of visual noise and makes it difficult for developers to spot the relevant changes.
In contrary, a semantic diff (or also called structural diff) understands the impact of a change. It can, for example, distinguish between relevant and irrelevant changes, and recognizes when changes correspond to a typical refactoring pattern, like moving code or renaming a function. Instead of showing only changed lines, a semantic diff will show an abstract description for some changes, e.g., that a function has been moved.
Our diff works similar to a compiler or interpreter. Given two source codes to compare, they are first converted to Abstract Syntax Trees (ASTs). This step adds additional information that enables us to filter out various style changes, like adding optional semicolons or commas in an array initialization.
In a second step, we match both trees to find out what has changed. Additional rules are applied to filter out more complex invariances. Afterwards the detected changes are translated back into a text diff representation.
The backend is built using Python and FastAPI, with some basic template rendering performed by jinja2. Most of the actual diff processing is done by an executable written in C++ that is invoked by the backend.
The frontend part is mostly based on our SemanticDiff Visual Studio Code extension and implements a custom diff viewer that only creates DOM elements for the currently visible text. It makes use of some third-party components that are listed here.
Please let us know in our issue tracker :-)