diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-07-27 16:01:55 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-07-27 17:47:59 -0700 |
commit | 6e1eeeebfb453fa7c871869c19375ce60fbd7413 (patch) | |
tree | 539c4a3fdf1756ae79770d5c4aaf6366f1d1525e /archive/2.vm/relayout | |
parent | 8846a7f85cc04b77b2fe8a67b6d317723437b00c (diff) | |
download | mu-6e1eeeebfb453fa7c871869c19375ce60fbd7413.tar.gz |
5485 - promote SubX to top-level
Diffstat (limited to 'archive/2.vm/relayout')
-rwxr-xr-x | archive/2.vm/relayout | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/archive/2.vm/relayout b/archive/2.vm/relayout new file mode 100755 index 00000000..8ea48920 --- /dev/null +++ b/archive/2.vm/relayout @@ -0,0 +1,65 @@ +#!/bin/bash +# Helper to change the numerical prefixes across the repo, say if you want to +# create room between 023 and 024, and so on. +# +# Assumes there's only ever one file with any numeric prefix. If you move +# 003trace.test.cc you might need to do some manual patch-up. + +set -e + +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 +ls [0-9]* |grep -v "trace.test" |sort -n | + 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() { + echo $1 |sed 's/^[0-9]*//' +} + +index=0 +cat .layout | + while read file + do + if [ ! -z $file ] + then + newfile=`printf "%03d" $index``root $file` + if [[ $newfile != $file ]] + then + echo git mv $file $newfile + git mv $file $newfile + fi + fi + index=$(($index+1)) + done + +rm .layout + +# Scenarios considered: +# Don't redo the layout if Vim exits with error. |