Created
March 28, 2018 10:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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