Skip to content

Instantly share code, notes, and snippets.

@diiq
Last active December 30, 2015 19:29
Show Gist options
  • Save diiq/7874563 to your computer and use it in GitHub Desktop.
Save diiq/7874563 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script works in tandem with git-branch-with-scope. If you
# branched normally, this commits as usual. It should be saved in
# .git/hooks/prepare-commit-msg.
message_file="$1"
current_branch=`git symbolic-ref -q --short HEAD`
scope_definition=".git/$current_branch-scope"
if [ -e $scope_definition ]
then
t_message_file=`mktemp /tmp/git-commit-with-scope-XXXXX`
(echo -e "\n\n"; sed -e 's/^/# /' "$scope_definition"; cat "$message_file") > "$t_message_file"
cat "$t_message_file" > "$message_file"
fi
@ejdyksen
Copy link

Getting this:

❯ ./prepare-commit-msg
git: 'current-branch' is not a git command. See 'git --help'.

Is this an alias in your environment?

I'm running the latest git (1.8.5.1).

@diiq
Copy link
Author

diiq commented Dec 19, 2013

@ejdyksen, there was a comment in two of these scripts regarding that alias and how to create it -- but just for you, I've removed both the comments and the alias from both. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment