1#!/bin/sh 2 3# hide output 4set -e 5 6# Update lints 7cargo dev update_lints 8git add clippy_lints/src/lib.rs 9git add clippy_lints/src/lib.*.rs 10 11# Formatting: 12# Git will not automatically add the formatted code to the staged changes once 13# fmt was executed. This collects all staged files rs files that are currently staged. 14# They will later be added back. 15# 16# This was proudly stolen and adjusted from here: 17# https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798 18files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true) 19if [ ! -z "${files}" ]; then 20 cargo dev fmt 21 git add $(echo "$files" | paste -s -d " " -) 22fi 23