summaryrefslogtreecommitdiffstats
path: root/bin/git-upstream-add
blob: b4a6a970024ebcb0b66b535f8f4f5bc28cd1feb1 (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
#!/bin/sh

set -e

if [ -n "$(git config --get user.signingKey)" ]
then
	GIT_OPTIONS="-S"
fi

VERSION="${1}"
COMMIT="${2}"

if [ -z "${VERSION}" ]
then
	echo "Usage: $(basename ${0}) VERSION"
	exit 1
fi

if [ -d debian ]
then
	echo "'debian': directory exists, aborting."
	exit 1
fi

if [ ! -d .git ]
then
	git init --shared
fi

git add -A -f
git commit -a -s -m "Adding upstream version ${VERSION}." --allow-empty ${GIT_OPTIONS}
git-upstream-tag ${VERSION} ${COMMIT}

CURRENT_BRANCH="$(git branch --show-current)"

if ! git branch | grep -qs upstream
then
	git branch -m ${CURRENT_BRANCH} upstream
fi