https://github.com/pavelzw/pixi-diff
Generate JSON diffs between pixi lockfiles
https://github.com/pavelzw/pixi-diff
conda pixi
Last synced: 6 months ago
JSON representation
Generate JSON diffs between pixi lockfiles
- Host: GitHub
- URL: https://github.com/pavelzw/pixi-diff
- Owner: pavelzw
- License: bsd-3-clause
- Created: 2025-01-24T23:40:30.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-01T17:37:14.000Z (6 months ago)
- Last Synced: 2025-04-13T09:12:23.930Z (6 months ago)
- Topics: conda, pixi
- Language: Rust
- Homepage: https://pixi.sh/latest/advanced/lockfile_diffs
- Size: 4.96 MB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[![License][license-badge]](LICENSE)
[![CI Status][ci-badge]][ci]
[![Conda Platform][conda-badge]][conda-url]
[![Conda Downloads][conda-downloads-badge]][conda-url]
[![Project Chat][chat-badge]][chat-url]
[![Pixi Badge][pixi-badge]][pixi-url][license-badge]: https://img.shields.io/github/license/pavelzw/pixi-diff?style=flat-square
[ci-badge]: https://img.shields.io/github/actions/workflow/status/pavelzw/pixi-diff/ci.yml?style=flat-square&branch=main
[ci]: https://github.com/pavelzw/pixi-diff/actions/
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/pixi-diff?style=flat-square
[conda-downloads-badge]: https://img.shields.io/conda/dn/conda-forge/pixi-diff?style=flat-square
[conda-url]: https://prefix.dev/channels/conda-forge/packages/pixi-diff
[chat-badge]: https://img.shields.io/discord/1082332781146800168.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2&style=flat-square
[chat-url]: https://discord.gg/kKV8ZxyzY4
[pixi-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json&style=flat-square
[pixi-url]: https://pixi.sh
# pixi-diff
A simple executable to generate a JSON diff (similar to `pixi update --json`) between two pixi lockfiles.
```text
$ pixi-diff pixi.lock.old pixi.lock.new
{
"version": 1,
"environment": {
"default": {
"osx-arm64": [
{
"name": "libmpdec",
"before": null,
"after": {
"conda": "https://conda.anaconda.org/conda-forge/osx-arm64/libmpdec-4.0.0-h99b78c6_0.conda",
"sha256": "f7917de9117d3a5fe12a39e185c7ce424f8d5010a6f97b4333e8a1dcb2889d16",
"md5": "7476305c35dd9acef48da8f754eedb40",
"depends": [
"__osx >=11.0"
],
"license": "BSD-2-Clause",
"license_family": "BSD",
"size": 69263,
"timestamp": 1723817629767
},
"type": "conda"
},
// ...
```## Install
```bash
pixi global install pixi-diff
```You can also use this tool in a temporary environment using `pixi exec`:
```bash
pixi exec pixi-diff pixi.lock.old pixi.lock.new
```## Usage
```text
Generate JSON diffs between pixi lockfilesUsage: pixi-diff [OPTIONS] [BEFORE] [AFTER]
Arguments:
[BEFORE] First lockfile to be compared
[AFTER] Second lockfile to be comparedOptions:
-b, --before First lockfile to be compared
-a, --after Second lockfile to be compared
--manifest-path Pixi manifest file. Used to determine whether a dependency is explicit
-v, --verbose... Increase logging verbosity
-q, --quiet... Decrease logging verbosity
-h, --help Print help
-V, --version Print version
```You can either specify both the old and new lockfile via CLI parameters:
```bash
pixi-diff pixi.lock.old pixi.lock.new
# or equivalently
pixi-diff --before pixi.lock.old --after pixi.lock.new
```Named pipes can be handy for comparing lockfiles from different states in your git history:
```bash
# bash / zsh
pixi-diff <(git show HEAD~20:pixi.lock) pixi.lock
# or equivalently
pixi-diff --before <(git show HEAD~20:pixi.lock) --after pixi.lock# fish
pixi-diff (git show HEAD~20:pixi.lock | psub) pixi.lock
# or equivalently
pixi-diff --before (git show HEAD~20:pixi.lock | psub) --after pixi.lock
```Or specify either the "before" or "after" lockfile via stdin:
```bash
git show HEAD~20:pixi.lock | pixi-diff --before - --after pixi.lock
```You can specify the manifest path (this tool tries out `pixi.toml` and `pyproject.toml` if not specified) to add `explicit: true/false` to your JSON diff.
If no manifest file is found, `explicit: true/false` is not added to the diff.```bash
pixi-diff pixi.lock.old pixi.lock.new --manifest-path pixi.toml
```### pixi-diff-to-markdown
This tool integrates with [pixi-diff-to-markdown](https://github.com/pavelzw/pixi-diff-to-markdown).
You can pass this tool's stdout to `pixi-diff-to-markdown` and generate markdown diffs this way.```bash
$ git show HEAD~20:pixi.lock | pixi-diff --after pixi.lock | pixi-diff-to-markdown
# Explicit dependencies
...
```#### View with md-tui
You can view this generated markdown file in your terminal using [md-tui](https://github.com/henriklovhaug/md-tui) (available on [conda-forge](https://prefix.dev/channels/conda-forge/packages/md-tui)).
```bash
git show HEAD~20:pixi.lock | pixi-diff --before - --after pixi.lock | pixi-diff-to-markdown > diff.md
mdt diff.md
# or using pixi exec
git show HEAD~20:pixi.lock | pixi exec pixi-diff --before - --after pixi.lock | pixi exec pixi-diff-to-markdown > diff.md
pixi exec -s md-tui -- mdt diff.md
```A couple of issues with this approach:
- md-tui does not support bold and italic links ([henriklovhaug/md-tui #91](https://github.com/henriklovhaug/md-tui/issues/91))
- md-tui does not support footnotes ([henriklovhaug/md-tui #162](https://github.com/henriklovhaug/md-tui/issues/162))
- md-tui does not support reading from stdin ([henriklovhaug/md-tui #167](https://github.com/henriklovhaug/md-tui/issues/167))
- md-tui does not support Windows ([henriklovhaug/md-tui #168](https://github.com/henriklovhaug/md-tui/issues/168))
- md-tui does not support the `` tag ([henriklovhaug/md-tui #169](https://github.com/henriklovhaug/md-tui/issues/169))