rancher / charts-build-scripts

Apache License 2.0
9 stars 32 forks source link

Document requirement for GNU Diff/Patch #130

Open mallardduck opened 4 months ago

mallardduck commented 4 months ago

The functionality of generating and applying the diff patches are dependent on local system diff and patch binaries.

Per these lines:

https://github.com/rancher/charts-build-scripts/blob/a7001e331fda7b61c8df358862f46436eaae9df2/pkg/diff/diff.go#L19 https://github.com/rancher/charts-build-scripts/blob/a7001e331fda7b61c8df358862f46436eaae9df2/pkg/diff/diff.go#L57

Unfortunately, a "normal assumption" would probably be that "This is all a golang script, so the execution shouldn't be affected by local environment variances." So without this requirement documented clearly then we can encounter unexpected behavior explained by "well it works on my machine".

This was all learned in a first hand experience based on PRs I was working on last friday. We were seeing that even if I made no changes at all and ran make charts then it would results in file modifications. Eventually it was all tracked down to the fact that on macOS they ship with a BSD based "Apple" version of diff and patch. See:

→ patch --version
patch 2.0-12u11-Apple

→ diff --version
Apple diff (based on FreeBSD diff)

After using brew to install gpatch and diffutils packages I have GNU versions and get expected results:

→ patch --version
GNU patch 2.7.6

→ diff --version
diff (GNU diffutils) 3.10