summaryrefslogtreecommitdiffstats
path: root/bin/git-upstream-add
diff options
context:
space:
mode:
Diffstat (limited to 'bin/git-upstream-add')
-rwxr-xr-xbin/git-upstream-add39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/git-upstream-add b/bin/git-upstream-add
new file mode 100755
index 0000000..b4a6a97
--- /dev/null
+++ b/bin/git-upstream-add
@@ -0,0 +1,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