Skip to content

Instantly share code, notes, and snippets.

View cm0s's full-sized avatar

Nicolas Forney cm0s

  • University of Geneva
  • Switzerland
View GitHub Profile
@cm0s
cm0s / prepare-commit-msg
Created December 18, 2018 22:56 — forked from fgeller/prepare-commit-msg
prefixes commit message with path of changed files. useful in mono-repo setup
#!/bin/sh
prefixes=$(git diff --cached --name-only | while read f ; do echo "${f%/*}" ; done | sort | uniq)
prefixes_count=$(echo $prefixes | wc -l)
if [ "$prefixes_count" -eq "1" ]; then
sed -i "1s;^;$prefixes: \n;" "$1"
fi