Commit cb57197b authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add automatic submodule updating

parent 926eecb3
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -60,6 +60,32 @@ get_shell()
	echo sh
}

update_submodules()
{
	git stash
	git submodule init
	git submodule sync
	git submodule update
	git submodule foreach 'git checkout origin/`
		git config -f ~/.gitmodules submodule.${name}.auto-update 2>/dev/null ||
			echo master`;
		cd $toplevel; git add $path'
	local updates="`git status --short -uno`"
	if [ -n "$updates" ]; then
		git commit -F- <<-END_MESSAGE
			Update submodules

			$updates

			Automatically generated:
			  source: .shell/funcs:update_submodules()
			  time:   `date`
			  host:   `hostname -f`
		END_MESSAGE
	fi
	git stash pop
}

do_update()
{
	local timestamp=${HOME}/.shell/.update
@@ -84,5 +110,6 @@ do_update()

	cd ~
	git pull --ff-only origin
	update_submodules
	cd - >/dev/null
}