blob: d680a943e3833a2dcc29c2ec28e868e8d9f6e539 (
plain)
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
|
#!/bin/sh
# how to use:
# put all of this in some directory (eg. /home/micah/bin/superproject-post-push.sh) and then do this in the git submodule directory:
# micah@minnow:~/leap/puppet/modules/apt$ git config alias.xpush "push && /home/micah/bin/superproject-post-push.sh"
# use git xpush for pushing
# this assumes a couple things:
# 1. you do the commit in the top level of the submodule (not any subdirectory within)
# 2. you have no local, uncomitted changes in your superproject when you do any submodule commit
# exit on any error
set -e
# change this variable to your superproject checkout
superproject=${HOME}/leap/puppet
submodule_base=`basename $PWD`
submodule=${submodule_base#puppet_}
# check out the latest version of the superproject
# note: this part is fragile, because if you have local, uncomitted changes in your superproject, then this pull will fail
cd ${superproject}
git pull
git submodule update --init
# check out latest version of submodule
# according to https://we.riseup.net/riseup+tech/puppet-git-submodules
cd ${superproject}/modules/${submodule}
git remote update
git merge origin/master
# commit and push the submodule update commit
cd ..
git add $submodule
git commit -m "automatic update of submodule $submodule_base"
git push
|