Skip to content

Instantly share code, notes, and snippets.

View franksteinberg's full-sized avatar

Frank Steinberg franksteinberg

View GitHub Profile
@franksteinberg
franksteinberg / prepare-commit-msg
Created February 10, 2021 21:19 — forked from kevindb/prepare-commit-msg
Prepend commit message with ticket number from branch name
#!/usr/bin/env python
# https://gist.github.com/kevindb/a360c8e90bcdf6364f1523a5787c8d89
import sys, re
from subprocess import check_output
commit_msg_filepath = sys.argv[1]
branch = check_output(['git', 'branch', '--show-current'])
@franksteinberg
franksteinberg / prepare-commit-msg.sh
Last active July 16, 2020 01:35 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
AFTER_FIRST_SLASH=$(echo "${BRANCH_NAME#*/}")