forked from GENIVI/genivi-dev-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-submodule-bump
More file actions
executable file
·32 lines (25 loc) · 889 Bytes
/
git-submodule-bump
File metadata and controls
executable file
·32 lines (25 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# Convenient script to create commit for update of submodules.
#
# NOTE: This script can only handle one submodule update. In the spirit of
# keeping commits atomic, we typically shouldn't update multiple submodules in
# the same commit anyway.
#
# Author: Zeeshan Ali <zeeshan.ali@pelagicore.com>
SHORTLOG="$*"
if test -z "${SHORTLOG}"; then
echo "Usage: ${0} <commit summary>"
exit 1
fi
CHANGED_MOD=$(git submodule status | grep '^+' | tr -d + | head -n 1)
if test -z "${CHANGED_MOD}"; then
echo "No module updated."
exit 2
fi
SUBMODULE=$(echo ${CHANGED_MOD} | cut -d' ' -f2)
NEWCOMMIT=$(echo ${CHANGED_MOD} | cut -d' ' -f1)
OLDCOMMIT=$(git diff ${SUBMODULE}|grep "^-Subproject"|cut -d' ' -f3)
MSG="${SUBMODULE}: ${SHORTLOG}
$(git -C ${SUBMODULE} log --no-merges --format="%h %s" ${OLDCOMMIT}..${NEWCOMMIT})
"
git commit -s -e -m "${MSG}" "${SUBMODULE}"