2016-10-31 15:11:02 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# Recommended command-line:
|
|
|
|
#
|
2016-11-03 13:00:47 +08:00
|
|
|
# commit-db.rb list-valid nightly|GIT_DIR=/your/rust/dir/.git ./build-src.sh
|
2016-10-31 15:11:02 +08:00
|
|
|
|
2018-12-17 07:30:27 +08:00
|
|
|
if [ $(uname) == 'Darwin' ]; then
|
|
|
|
alias tac='tail -f'
|
|
|
|
fi
|
|
|
|
|
2016-10-31 15:11:02 +08:00
|
|
|
prompt_changes() {
|
|
|
|
local MAIN_GIT_DIR="$GIT_DIR"
|
|
|
|
local GIT_DIR=./.git CORE_IO_COMMIT=$IO_COMMIT
|
|
|
|
git init > /dev/null
|
|
|
|
git add .
|
2016-11-03 13:00:47 +08:00
|
|
|
git commit -m "rust src import" > /dev/null
|
2016-10-31 15:11:02 +08:00
|
|
|
export CORE_IO_COMMIT
|
2018-12-17 07:30:27 +08:00
|
|
|
|
2016-10-31 15:11:02 +08:00
|
|
|
bold_arrow; echo 'No patch found for' $IO_COMMIT
|
|
|
|
bold_arrow; echo 'Nearby commit(s) with patches:'
|
|
|
|
echo
|
|
|
|
GIT_DIR="$MAIN_GIT_DIR" git_commits_ordered '%H %cd' $(get_patch_commits) $IO_COMMIT | \
|
|
|
|
grep --color=always -1 $IO_COMMIT | sed /$IO_COMMIT/'s/$/ <=== your commit/'
|
|
|
|
echo
|
2018-12-17 07:30:27 +08:00
|
|
|
bold_arrow; echo -e "Try applying one of those using: \033[1;36mtry_patch COMMIT\033[0m"
|
|
|
|
bold_arrow; echo -e "Remember to test your changes with: \033[1;36mcargo build\033[0m"
|
|
|
|
bold_arrow; echo -e "Make your changes now (\033[1;36mctrl-D\033[0m when finished)"
|
2016-11-03 13:00:47 +08:00
|
|
|
bash_diff_loop "No changes were made"
|
2016-10-31 15:11:02 +08:00
|
|
|
bold_arrow; echo "Saving changes as $IO_COMMIT.patch"
|
|
|
|
git clean -f -x
|
|
|
|
git diff > ../../patches/$IO_COMMIT.patch
|
|
|
|
rm -rf .git
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ ! -t 1 ] || [ ! -t 2 ]; then
|
|
|
|
echo "==> /dev/stdout or /dev/stderr is not attached to a terminal!"
|
|
|
|
echo "==> This script must be run interactively."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
2016-11-03 13:00:47 +08:00
|
|
|
|
|
|
|
. ./functions.sh
|
|
|
|
|
2016-10-31 15:11:02 +08:00
|
|
|
PATCH_DIR="$PWD/patches"
|
|
|
|
COMPILER_COMMITS=$(cat)
|
|
|
|
IO_COMMITS=$(get_io_commits|sort -u)
|
|
|
|
PATCH_COMMITS=$(get_patch_commits|sort -u)
|
|
|
|
NEW_COMMITS=$(comm -2 -3 <(echo_lines $IO_COMMITS) <(echo_lines $PATCH_COMMITS))
|
|
|
|
OLD_COMMITS=$(comm -1 -2 <(echo_lines $IO_COMMITS) <(echo_lines $PATCH_COMMITS))
|
|
|
|
|
2016-11-03 13:00:47 +08:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
2016-10-31 15:11:02 +08:00
|
|
|
find src -mindepth 1 -type d -prune -exec rm -rf {} \;
|
|
|
|
|
|
|
|
for IO_COMMIT in $OLD_COMMITS $(git_commits_ordered %H $NEW_COMMITS|tac); do
|
|
|
|
if ! [ -d src/$IO_COMMIT ]; then
|
|
|
|
prepare_version
|
2018-12-17 07:30:27 +08:00
|
|
|
|
2016-10-31 15:11:02 +08:00
|
|
|
if [ -f patches/$IO_COMMIT.patch ]; then
|
2016-11-03 13:00:47 +08:00
|
|
|
bold_arrow; echo "Patching $IO_COMMIT"
|
2016-10-31 15:11:02 +08:00
|
|
|
patch -s -p1 -d src/$IO_COMMIT < patches/$IO_COMMIT.patch
|
|
|
|
else
|
|
|
|
cd src/$IO_COMMIT
|
|
|
|
prompt_changes
|
|
|
|
cd ../..
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-12-17 07:30:27 +08:00
|
|
|
if [ $(uname) == 'Darwin' ]; then
|
|
|
|
OLD_GIT_PERM=$(stat -f %Op .git)
|
|
|
|
else
|
|
|
|
OLD_GIT_PERM=$(stat --printf=%a .git)
|
|
|
|
fi
|
2016-11-03 13:00:47 +08:00
|
|
|
trap "chmod $OLD_GIT_PERM .git; exit 1" SIGINT
|
2016-10-31 15:11:02 +08:00
|
|
|
chmod 000 .git
|
2017-04-10 05:06:38 +08:00
|
|
|
cargo ${1:-package}
|
2016-11-03 13:00:47 +08:00
|
|
|
chmod $OLD_GIT_PERM .git
|