fix(rake-fast): make .rake_tasks write atomic (#12108)

This commit is contained in:
Oleg Grigoriev 2023-12-20 22:52:27 +03:00 committed by GitHub
parent 0bb00eddbb
commit 2a15741656
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,14 +43,17 @@ _tasks_changed () {
} }
_rake_generate () { _rake_generate () {
echo "version:$_rake_tasks_version" > .rake_tasks local rake_tasks_content="version:$_rake_tasks_version\n"
rake_tasks_content+=$(rake --silent --tasks --all \
rake --silent --tasks --all \
| sed "s/^rake //" | sed "s/\:/\\\:/g" \ | sed "s/^rake //" | sed "s/\:/\\\:/g" \
| sed "s/\[[^]]*\]//g" \ | sed "s/\[[^]]*\]//g" \
| sed "s/ *# /\:/" \ | sed "s/ *# /\:/" \
| sed "s/\:$//" \ | sed "s/\:$//")
>> .rake_tasks
local rake_tasks_file="$(mktemp -t .rake_tasks.XXXXXX)"
echo $rake_tasks_content > $rake_tasks_file
mv $rake_tasks_file .rake_tasks
} }
_rake () { _rake () {