This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/.circleci/update/apply_patch

46 lines
1 KiB
Text
Raw Normal View History

#!/usr/bin/env bash
## apply_patch Apply patch to the target(official spacemacs) repository
##
## Copyright (c) 2014-2021 Sylvain Benner & Contributors
##
## Author: Eugene Yaremenko
## URL: https://github.com/syl20bnr/spacemacs
##
## This file is not part of GNU Emacs.
##
## License: GPLv3
2021-08-01 20:34:01 +00:00
exit_if_no_patchfile
2021-07-05 23:15:33 +00:00
echo_headline "Cloning target repository"
target_URL="https://github.com/${prj_owner}/${prj_repo}.git"
2021-07-07 10:25:03 +00:00
git clone "${target_URL}" -b "${PR_BRANCH}" "/tmp/${PUBLISH}"
2021-07-05 23:15:33 +00:00
if [ $? -ne 0 ]; then
echo "Failed to clone \"${target_URL}\""
exit 2
fi
2021-07-05 23:15:33 +00:00
cd "/tmp/${PUBLISH}"
echo_headline "Patching"
git apply --reject --whitespace=fix "/tmp/${PUBLISH}.patch"
if [ $? -ne 0 ]; then
echo "Failed to apply \"/tmp/${PUBLISH}.patch\"."
exit 2
fi
2021-07-05 23:15:33 +00:00
git add --all
2021-08-01 20:34:01 +00:00
2021-08-25 22:22:52 +00:00
if [[ -z $(git status -s) ]]; then
2021-08-25 22:37:03 +00:00
echo "Nothing to commit."
rm "/tmp/${PUBLISH}.patch"
exit 0
else
2021-08-01 20:34:01 +00:00
echo_headline "Creating commit"
git commit -m "[bot] \"${PUBLISH}\" $(date -u)"
if [ $? -ne 0 ]; then
echo "Failed to create commit."
exit 2
fi
fi