brettcannon,
@brettcannon@fosstodon.org avatar

Looking for a Bash one-liner to tell by exit code whether your Git checkout is dirty?

if [ -n "$(git status --porcelain)" ]; then (exit 1); fi

I sought this out for GitHub Actions so that I could set up a formatting command for a project and then check in CI if it would change anything instead of having a second command just for the check (e.g. black followed by this in CI instead of having a separate, dedicated black --check just for CI). Basically trying up the DRY on maintenance stuff

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • Durango
  • DreamBathrooms
  • khanakhh
  • GTA5RPClips
  • osvaldo12
  • magazineikmin
  • mdbf
  • InstantRegret
  • rosin
  • Youngstown
  • slotface
  • everett
  • kavyap
  • ngwrru68w68
  • megavids
  • modclub
  • tester
  • tacticalgear
  • cubers
  • thenastyranch
  • cisconetworking
  • ethstaker
  • Leos
  • provamag3
  • normalnudes
  • anitta
  • JUstTest
  • lostlight
  • All magazines