aboutsummaryrefslogtreecommitdiff
path: root/lib/subcommands/pull.bash
blob: 4f2ae9976a66db35e8d0ba3214e61c8a1e48d093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2023 Patrick Spek <p.spek@tyil.nl>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

subcommand()
{
	local dirty

	notice "bashtard/pull" "Pulling latest changes in $BASHTARD_ETCDIR"

	if ! git -C "$BASHTARD_ETCDIR" diff-index --quiet HEAD --
	then
		dirty=1
	fi

	[[ -n $dirty ]] && git -C "$BASHTARD_ETCDIR" stash
	git -C "$BASHTARD_ETCDIR" pull origin master || return 4
	git -C "$BASHTARD_ETCDIR" submodule update --init --recursive || return 4
	[[ -n $dirty ]] && git -C "$BASHTARD_ETCDIR" stash pop
}