Normally when I commit a change to a submodule in Git (and if that's the only change), I will provide the result of
git diff <submodule-name> to the body of the commit message (with
diff.submodule set to
log in my git config). So the message would look something like:
Updated Core Submodule Submodule Core eaedd3f..0721763: < Fixed ZA-123: Crash in rendering module < Merge 'develop' into 'master'
I've been trying to write a script that will automate this, to which I can tie to an alias in my git config. To generate the text above, ideally I'd like to run a command such as:
$ git submodule-commit Core
This would perform the following (roughly):
- Stage any change to specified submodule (
Corein this case)
- Diff the change to the submodule and store that output text for the message generated later
git commitand provide the subject line (
Updated $1 Submodule, or something of that sort, where
Corein this example).
- Add the stored diff result from earlier to the commit message as well
I've not had any luck writing a simple script for this. I'm not very experienced with bash / shell scripts. Could anyone help provide an implementation that accomplishes this?