rust-raspberrypi-OS-tutorials/utils/helpers/diff_tut_folders.bash

31 lines
718 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2019-10-08 07:14:16 +00:00
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2018-2019 Andre Richter <andre.o.richter@gmail.com>
DIFF=$(
diff -uNr \
-x README.md \
-x kernel \
-x kernel8.img \
-x Cargo.lock \
-x target \
$1 $2 \
2019-10-08 07:14:16 +00:00
| sed -r "s/[12][90][127][90]-.*//g" \
2019-10-20 12:42:59 +00:00
| sed -r "s/[[:space:]]*$//g" \
| sed -r "s/%/modulo/g"
)
2019-10-08 07:14:16 +00:00
HEADER="## Diff to previous"
ORIGINAL=$(
cat $2/README.md \
| sed -rn "/$HEADER/q;p"
)
printf "$ORIGINAL" > "$2/README.md"
printf "\n\n$HEADER\n" >> "$2/README.md"
printf "\`\`\`diff\n" >> "$2/README.md"
printf "${DIFF//'diff -uNr -x README.md -x kernel -x kernel8.img -x Cargo.lock -x target'/'\ndiff -uNr'}" >> "$2/README.md"
printf "\n\`\`\`\n" >> "$2/README.md"