summaryrefslogtreecommitdiff
path: root/pbs-package-merge
blob: f99484bec815c114485aae76634c8718a05e30fd (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
39
40
41
42
43
#!/bin/bash -euE

. libremessages

cmd=${0##*/}
usage() {
	echo "Usage: $cmd [OPTIONS]"
	echo 'Fetches and merges changes from an upstream package'
	echo ''
	echo 'The repository and refspec that are merged are controlled by the'
	echo 'file `pbstrack`.'
	echo ''
	echo 'Options:'
	echo '  -h            Show this message'
}

main() {
	while getopts 'h' arg; do
		case $arg in
			h) usage; return 0;;
			*) usage; return 1;;
		esac
	done
	shift $(($OPTIND - 1))
	if [[ $# > 0 ]]; then
		usage
		return 1
	fi

	if ! git rev-parse --git-dir &>/dev/null; then
		error "Must be in a package (git) directory"
		return 1
	fi
	cd "$(git rev-parse --show-cdup)"

	if [[ ! -r pbstrack ]]; then
		error "No pbstrack file found, don't know where to pull from"
		return 1
	fi
	git pull $(cat pbstrack)
}

main "$@"