niv icon indicating copy to clipboard operation
niv copied to clipboard

Present a diff of the update before writing it to file

Open nmattia opened this issue 6 years ago • 4 comments

I'd like to have niv produce a (git-like) diff of the PackageSpec before it's written to file. This could be a CLI opt like niv update --dry-run or niv update --give-choice.

Note: we're gonna run into some difficulties if #73 is implemented.

nmattia avatar Jun 12 '19 22:06 nmattia

Isn't this what version control is for? I can see that outputting if something was changed for an individual package would be helpful.

andir avatar Jul 31 '21 10:07 andir

If possible, there could be some value on having this information without downloading the source itself. Here is a quick mock-up of the output of a diff-like command

nixpkgs
10,12c10,12
<         "rev": "491a0bbc69c053c2a4fca69be7960ec8ffab56a4",
<         "sha256": "0agd8xhm5ddww9m4v7lbp782zn0fi5rw2f3z1rlw89lph307vxlz",
<         "url": "https://github.com/NixOS/nixpkgs/archive/491a0bbc69c053c2a4fca69be7960ec8ffab56a4.tar.gz"
---
>         "rev": "47892abb69c053c2a4fca69be7960ec8ffab56a4",
>         "sha256": <not computed>,
>         "url": "https://github.com/NixOS/nixpkgs/archive/47892abb69c053c2a4fca69be7960ec8ffab56a4.tar.gz"

refnil avatar Aug 01 '21 07:08 refnil

What is the value you are thinking of? I can see it as purely information to show the change in revision (abcdef -> defga123) but not the diff of that file. Also, why is it important that this happens before the update? Do you expect to skip an update when you see a specific commit id there?

andir avatar Aug 02 '21 15:08 andir

What about a flag like --dry? That means that niv update nixpkgs --dry would either show a diff, or the new version. I like the diff, I think some output like Terraform's plan would be good.

nmattia avatar Aug 03 '21 08:08 nmattia