2016-10-12 05:12:17 +00:00
|
|
|
|
#!/bin/bash
|
2015-03-17 15:42:38 +00:00
|
|
|
|
# Helper to change the numerical prefixes across the repo, say if you want to
|
|
|
|
|
# create room between 023 and 024, and so on.
|
2015-04-17 18:04:58 +00:00
|
|
|
|
#
|
|
|
|
|
# Assumes there's only ever one file with any numeric prefix. If you move
|
2016-10-12 05:11:58 +00:00
|
|
|
|
# 003trace.test.cc you might need to do some manual patch-up.
|
2015-03-17 15:42:38 +00:00
|
|
|
|
|
2018-07-23 15:39:44 +00:00
|
|
|
|
set -e
|
|
|
|
|
|
2015-03-17 15:42:38 +00:00
|
|
|
|
if [[ $# -eq 0 && `git diff HEAD |wc -l` -gt 0 ]]
|
|
|
|
|
then
|
|
|
|
|
echo "Uncommitted changes"
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $# -gt 0 ]] # dry run
|
|
|
|
|
then
|
|
|
|
|
git() {
|
|
|
|
|
echo $*
|
|
|
|
|
}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
index=0
|
2015-04-30 17:40:02 +00:00
|
|
|
|
ls [0-9]* |grep -v "trace.test" |sort -n |
|
2015-03-17 15:42:38 +00:00
|
|
|
|
while read file
|
|
|
|
|
do
|
|
|
|
|
while [[ $file != `printf "%03d" $index`* ]]
|
|
|
|
|
do
|
|
|
|
|
echo
|
|
|
|
|
index=$(($index+1))
|
|
|
|
|
done
|
|
|
|
|
echo $file
|
|
|
|
|
index=$(($index+1))
|
|
|
|
|
done > .layout
|
|
|
|
|
|
|
|
|
|
vim -c "set nu" .layout
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
root() {
|
2016-10-06 22:58:34 +00:00
|
|
|
|
echo $1 |sed 's/^[0-9]*//'
|
2015-03-17 15:42:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
index=0
|
|
|
|
|
cat .layout |
|
|
|
|
|
while read file
|
|
|
|
|
do
|
|
|
|
|
if [ ! -z $file ]
|
|
|
|
|
then
|
|
|
|
|
newfile=`printf "%03d" $index``root $file`
|
|
|
|
|
if [[ $newfile != $file ]]
|
|
|
|
|
then
|
2018-07-23 15:39:44 +00:00
|
|
|
|
echo git mv $file $newfile
|
2015-03-17 15:42:38 +00:00
|
|
|
|
git mv $file $newfile
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
index=$(($index+1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
rm .layout
|
2018-07-23 15:39:44 +00:00
|
|
|
|
|
|
|
|
|
# Scenarios considered:
|
|
|
|
|
# Don't redo the layout if Vim exits with error.
|