From 95cc135bacb3130402d2f1bbc69c9788ca791841 Mon Sep 17 00:00:00 2001
From: Nick Cameron <ncameron@mozilla.com>
Date: Fri, 22 Apr 2016 19:19:09 +1200
Subject: [PATCH] Add a bootstrap script for running rustfmt on itself.

---
 bootstrap.sh | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100755 bootstrap.sh

diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755
index 00000000000..c84b66340a8
--- /dev/null
+++ b/bootstrap.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Make sure you double check the diffs after running this script - with great
+# power comes great responsibility.
+# We deliberately avoid reformatting files with rustfmt comment directives.
+
+cargo build
+
+target/debug/rustfmt --write-mode=overwrite src/lib.rs
+target/debug/rustfmt --write-mode=overwrite src/bin/rustfmt.rs
+target/debug/rustfmt --write-mode=overwrite src/bin/cargo-fmt.rs
+target/debug/rustfmt --write-mode=overwrite tests/system.rs
+
+for filename in tests/target/*.rs; do
+    if ! grep -q "rustfmt-" "$filename"; then
+        target/debug/rustfmt --write-mode=overwrite $filename
+    fi
+done