Skip to content

Instantly share code, notes, and snippets.

@fatso83
Created March 28, 2018 10:01
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 fatso83/5547fcfa37c38e26dc7f6fe8d8b8eda9 to your computer and use it in GitHub Desktop.
Save fatso83/5547fcfa37c38e26dc7f6fe8d8b8eda9 to your computer and use it in GitHub Desktop.
If you patched the source release docs, but still need to apply the patch against the released docs, try this script
#!/bin/bash
usage(){
cat << EOF
Usage: patch.sh my-patch-file.patch
Will try to apply the patch file a files matching the names in the patch file
in each sub-directory
You might need to modify the patch.
Example patch file might look like this:
--- stubs.md
+++ stubs.md
@@ -110,11 +110,11 @@ This is useful to be more expressive in your assertions, where you can access th
"test should stub method differently based on arguments": function () {
var callback = sinon.stub();
callback.withArgs(42).returns(1);
- callback.withArgs(1).throws("TypeError");
+ callback.withArgs(1).throws("name");
callback(); // No return value, no exception
callback(42); // Returns 1
- callback(1); // Throws TypeError
+ callback(1); // Throws Error("name")
}
EOF
}
if [[ $# < 1 ]]; then
usage;
exit 1;
fi
get_abs_filename() {
# $1 : relative filename
if [ -d "$(dirname "$1")" ]; then
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
fi
}
PATCH=$(get_abs_filename $1)
apply-patch-in-dir(){
local dir="$1"
pushd "$dir"
patch < "$PATCH"
popd
}
for dir in $(find -type d -maxdepth 1 -not -name .); do
apply-patch-in-dir $dir
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment