Skip to content

Instantly share code, notes, and snippets.

@ginkgomzd
Last active March 4, 2021 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ginkgomzd/a12e8e25e01e3dad81975d65eb3a5e9e to your computer and use it in GitHub Desktop.
Save ginkgomzd/a12e8e25e01e3dad81975d65eb3a5e9e to your computer and use it in GitHub Desktop.
Compare two directories and generate separate patch files and a list of unique files.
BEGIN {
patch_file = "ERR" # initialize
patches = "patches" # dir to output patches
if (ENVIRON["PATCH_DIR"]) {
patches = ENVIRON["PATCH_DIR"]
}
system("test -d " patches " || mkdir -p " patches)
}
/^diff/ { next }
/Sólo en/ { next }
/Only in/ { next }
/^-{3}|+{3}/ {
setOutput()
}
{
print $0 >> patch_file
}
function setOutput( file_path, path, new_file) {
file_path = $2
split(file_path, path, "/")
new_file = patches "/" path[length(path)] ".patch"
if (new_file != patch_file) {
system("truncate --size 0 " new_file )
}
patch_file = new_file
}
@ginkgomzd
Copy link
Author

e.g.

diff -ur release/ site/ | awk -f split-diffs.awk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment