Skip to content

Instantly share code, notes, and snippets.

@suTerminus
Created March 22, 2022 08:38
Show Gist options
  • Select an option

  • Save suTerminus/2ab666c5f614f136221ce368e5c0e577 to your computer and use it in GitHub Desktop.

Select an option

Save suTerminus/2ab666c5f614f136221ce368e5c0e577 to your computer and use it in GitHub Desktop.
small script which uses branch names to automatically set "<type>[optional scope]" according to conventional commit guidelines.
#!/bin/bash
if [ -z "$2" ]
then
t=$(git branch --show-current | awk -F/ '{$NF=""} 1' | awk '{s=($1=="fix" || $1=="hotfix")?"fix":"feat";print s;}')
m=$1
else
t=$1
m=$2
fi
i=$(git branch --show-current | awk -F/ '{print $2}' | awk -F- '{print $1"-"$2}')
fm="$t($i):$m"
echo $fm
git commit -m $fm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment