68 lines
1.7 KiB
Bash
Executable file
68 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
## open_pr Opens PR to Spacemacs repository with built-in updates
|
|
##
|
|
## 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
|
|
|
|
skip_when_non_official_repo
|
|
|
|
if [ ! -f /tmp/built_in.patch ]; then
|
|
echo "Nothing to update."
|
|
exit 0
|
|
fi
|
|
|
|
echo_headline "Cloning target repository"
|
|
target_URL="https://github.com/${prj_owner}/${prj_repo}.git"
|
|
git clone "${target_URL}" -b "${CIRCLE_BRANCH}" "/tmp/${PUBLISH}"
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to clone \"${target_URL}\""
|
|
exit 2
|
|
fi
|
|
|
|
cd "/tmp/${PUBLISH}"
|
|
|
|
echo_headline "Applying built-in patch"
|
|
if [ ! -f /tmp/built_in.patch ]; then
|
|
echo "Built-in files don't need updating. Aborting."
|
|
else
|
|
git am < /tmp/built_in.patch
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to apply built-in patch."
|
|
exit 2
|
|
fi
|
|
|
|
fi
|
|
|
|
echo_headline "Pushing changes to bot repository"
|
|
/tmp/hub fork
|
|
if [ $? -ne 0 ]; then
|
|
echo "hub fork failed"
|
|
exit 2
|
|
fi
|
|
fork_url="https://${UPD_BOT_LONIG}:${UPD_BOT_GIT_TK}"
|
|
fork_url+="@github.com/${UPD_BOT_LONIG}/${PUBLISH}.git"
|
|
git remote set-url "${UPD_BOT_LONIG}" "${fork_url}"
|
|
/tmp/hub push -f "${UPD_BOT_LONIG}" "${CIRCLE_BRANCH}" > /dev/null 2>&1
|
|
# prevent token leak ^^^^^^^^^^^^^^
|
|
if [ $? -ne 0 ]; then
|
|
echo "hub push to \"${BOT_NAME}\" failed"
|
|
exit 2
|
|
fi
|
|
|
|
echo_headline "Opening PR to Spacemacs repo"
|
|
echo "[bot] Auto-update" > msg
|
|
echo >> msg
|
|
echo "Merge with care - I'm just a stupid bot. Beep boop." >> msg
|
|
/tmp/hub pull-request -b "${CIRCLE_BRANCH}" -F msg
|
|
if [ $? -ne 0 ]; then
|
|
echo "Seems like PR already exists (not a problem)"
|
|
fi
|
|
|
|
echo_headline "Done!"
|