forked from debops/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-submodules
executable file
·47 lines (29 loc) · 990 Bytes
/
update-submodules
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Update git submodules and commit new version of the documentation
set -e
# Get current checkout
current_checkout="$(git rev-parse HEAD)"
# Get latest state of the repository
git fetch
# Get new checkout id
new_checkout="$(git rev-parse FETCH_HEAD)"
if [ "${current_checkout}" != "${new_checkout}" ] ; then
# Switch current checkout to the new state
git reset --hard FETCH_HEAD
# Get latest updates from all submodules
git submodule update --init --remote
# Commit all changes
git commit --all --message 'Updated all submodules to latest master'
# Push changes to the origin
git push
else
# Get latest updates from all submodules
git submodule update --init --remote
# Check if there are uncommitted changes
if ! $(git diff --quiet && git diff --cached --quiet) ; then
# Commit all changes
git commit --all --message 'Updated all submodules to latest master'
# Push changes to the origin
git push
fi
fi