From bdde4dc966ca865e48c5e00e5bb3445118fa30d6 Mon Sep 17 00:00:00 2001
From: Matous Hybl <hyblmatous@gmail.com>
Date: Wed, 8 Dec 2021 12:33:41 +0100
Subject: [PATCH] Enable running ci.sh locally multiple-times.

---
 .gitignore |  4 ++++
 ci.sh      | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 7faa2c32d..92f9a32b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,7 @@ Cargo.lock
 third_party
 /Cargo.toml
 stm32-metapac-gen/out/
+stm32-metapac-backup
+stm32-metapac/src/chips
+stm32-metapac/src/peripherals
+out/
diff --git a/ci.sh b/ci.sh
index 6beea8677..ab0448721 100755
--- a/ci.sh
+++ b/ci.sh
@@ -6,9 +6,17 @@ export CARGO_TARGET_DIR=$PWD/target_ci
 export RUSTFLAGS=-Dwarnings
 export DEFMT_LOG=trace
 
-find . -name '*.rs' -not -path '*target*' -not -path '*stm32-metapac-gen/out/*'  | xargs rustfmt --check  --skip-children --unstable-features --edition 2018
+find . -name '*.rs' -not -path '*target*' -not -path '*stm32-metapac-gen/out/*' -not -path '*stm32-metapac/src/*' | xargs rustfmt --check  --skip-children --unstable-features --edition 2018
 
 # Generate stm32-metapac
+if [ ! -d "stm32-metapac-backup" ]
+then
+    cp -r stm32-metapac stm32-metapac-backup
+fi
+
+rm -rf stm32-metapac
+cp -r stm32-metapac-backup stm32-metapac
+
 # for some reason Cargo stomps the cache if we don't specify --target.
 # This happens with vanilla Cargo, not just cargo-batch. Bug?
 (cd stm32-metapac-gen; cargo run --release --target x86_64-unknown-linux-gnu)