about summary refs log tree commit diff stats
path: root/relayout
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-05 21:17:24 -0700
commitb96af395b9af2ff9df94b3e82213171f30827c8d (patch)
tree17c8c12648ccc25625e2534ec8d74fbe8f1542cc /relayout
parent2e3b597fe85b654e82b891c22d50754fa5a26156 (diff)
downloadmu-b96af395b9af2ff9df94b3e82213171f30827c8d.tar.gz
1276 - make C++ version the default
I've tried to update the Readme, but there are at least a couple of issues.
Diffstat (limited to 'relayout')
-rwxr-xr-xrelayout64
1 files changed, 64 insertions, 0 deletions
diff --git a/relayout b/relayout
new file mode 100755
index 00000000..e5f9a164
--- /dev/null
+++ b/relayout
@@ -0,0 +1,64 @@
+#!/usr/bin/env zsh
+# 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.tests you might need to do some manual patch-up.
+
+setopt extendedglob
+
+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
+    echo $file >&2
+    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 |perl -pwe '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
+        git mv $file $newfile
+      fi
+    fi
+    index=$(($index+1))
+  done
+
+#
+
+rm .layout