mirror of
https://github.com/Fishwaldo/build.git
synced 2025-06-22 22:28:46 +00:00
Improve patch making (#2070)
* Improve patch making * Better default patch name * Remove the patch file in the sources since we only need to extract the name
This commit is contained in:
parent
d16af794fe
commit
56f7fa2b9e
1 changed files with 23 additions and 2 deletions
|
@ -758,7 +758,14 @@ userpatch_create()
|
|||
local patch="$DEST/patch/$1-$LINUXFAMILY-$BRANCH.patch"
|
||||
|
||||
# apply previous user debug mode created patches
|
||||
[[ -f $patch ]] && display_alert "Applying existing $1 patch" "$patch" "wrn" && patch --batch --silent -p1 -N < "${patch}"
|
||||
if [[ -f $patch ]]; then
|
||||
display_alert "Applying existing $1 patch" "$patch" "wrn" && patch --batch --silent -p1 -N < "${patch}"
|
||||
# read title of a patch in case Git is configured
|
||||
if [[ -n $(git config user.email) ]]; then
|
||||
COMMIT_MESSAGE=$(cat "${patch}" | grep Subject | sed -n -e '0,/PATCH/s/.*PATCH]//p' | xargs)
|
||||
display_alert "Patch name extracted" "$COMMIT_MESSAGE" "wrn"
|
||||
fi
|
||||
fi
|
||||
|
||||
# prompt to alter source
|
||||
display_alert "Make your changes in this directory:" "$(pwd)" "wrn"
|
||||
|
@ -768,7 +775,21 @@ userpatch_create()
|
|||
git add .
|
||||
# create patch out of changes
|
||||
if ! git diff-index --quiet --cached HEAD; then
|
||||
git diff --staged > "${patch}"
|
||||
# If Git is configured, create proper patch and ask for a name
|
||||
if [[ -n $(git config user.email) ]]; then
|
||||
display_alert "Add / change patch name" "$COMMIT_MESSAGE" "wrn"
|
||||
read -e -p "Patch description: " -i "$COMMIT_MESSAGE" COMMIT_MESSAGE
|
||||
[[ -z "$COMMIT_MESSAGE" ]] && COMMIT_MESSAGE="Patching something"
|
||||
git commit -s -m "$COMMIT_MESSAGE"
|
||||
git format-patch -1 HEAD --stdout --signature="Created with Armbian build tools https://github.com/armbian/build" > "${patch}"
|
||||
PATCHFILE=$(git format-patch -1 HEAD)
|
||||
rm $PATCHFILE # delete the actual file
|
||||
# create a symlink to have a nice name ready
|
||||
find $DEST/patch/ -type l -delete # delete any existing
|
||||
ln -sf $patch $DEST/patch/$PATCHFILE
|
||||
else
|
||||
git diff --staged > "${patch}"
|
||||
fi
|
||||
display_alert "You will find your patch here:" "$patch" "info"
|
||||
else
|
||||
display_alert "No changes found, skipping patch creation" "" "wrn"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue