about summary refs log tree commit diff stats
path: root/cpp/relayout
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-17 08:42:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-17 09:06:48 -0700
commitb1bbe92da37dd44df458ffa122e052612bb9eff3 (patch)
tree976cde85c97d4877eb8c1e5151a919406fdd1049 /cpp/relayout
parentc062697c9ff3c8cb0938f56bed3df2af3d122bd6 (diff)
downloadmu-b1bbe92da37dd44df458ffa122e052612bb9eff3.tar.gz
945 - move 'transform' layer to before 'run'
Diffstat (limited to 'cpp/relayout')
-rwxr-xr-xcpp/relayout61
1 files changed, 61 insertions, 0 deletions
diff --git a/cpp/relayout b/cpp/relayout
new file mode 100755
index 00000000..e0b38c4b
--- /dev/null
+++ b/cpp/relayout
@@ -0,0 +1,61 @@
+#!/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.
+
+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 "^002trace.tests$" |sort -n |perl -pwe 's/\..*//' |
+  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]*//' |perl -pwe 's/\..*//'
+}
+
+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