Skip to content

Instantly share code, notes, and snippets.

@cam8001
Last active December 20, 2023 19:40
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save cam8001/9307192 to your computer and use it in GitHub Desktop.
Save cam8001/9307192 to your computer and use it in GitHub Desktop.
Apply a patch directly from a URL without downloading it first.
#!/bin/bash
# Downloads and applies a patch from Drupal.org.
if [ -z "$1" ]
then
echo "You need to supply a URL to a patch file."
exit
fi
URL=$1;
# Download a patch and apply it.
curl $URL | git apply -v --index
# Commit patch and add a log message.
git commit -m "Applied $URL."
@fed51
Copy link

fed51 commented Mar 17, 2020

In the commit line, you could use parameter expansion to cleanup the URL and to display just the patch file name.

git commit -m "Applied ${URL##*/}."

The result would be "Applied <file.patch>" as opposed to a potentially long ugly commit message.

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