Commit changes immediately to git using Rust
Submitted by clemens on Wed, 2020/12/09 - 12:43pm
Having a trail of your coding flow can be handy or will explain the longing question about 'what was i thinking' when resolving problems of https://adventofcode.com/
Warning: this script needs Rust (unfortunately) installed
#!/usr/bin/env bash ### File : watcher.bash ### Location : somewhere outside project dir ### Install : `cargo install cargo-watch` ### Then run : `cargo watch --shell ../watcher.bash` echo "===== watcher.bash =====" echo "" # Show user updates git status # Add files in the source directory git add src # Make sure other files already in the repo to get added during this commit. git commit -am "`date +%Y-%m-%dT%H:%m`"
Add this to the end of the file to make your Rust code clearer
# Format code after commit to inform the user (trusting his/her editor) cargo fmt cargo build if [ $? -eq 0 ] then cargo test if [ $? -eq 0 ] then # Run your project exec cargo run else echo "Test failed" fi else echo "Build failed" fi echo "----- done -----" exit 0