add script to automate importing upstream
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 28 Jan 2017 22:36:09 +0000 (15:36 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 28 Jan 2017 22:36:09 +0000 (15:36 -0700)
maint/import_upstream.sh [new file with mode: 0755]

diff --git a/maint/import_upstream.sh b/maint/import_upstream.sh
new file mode 100755 (executable)
index 0000000..f591813
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+: <<'=cut'
+=pod
+
+=head1 NAME
+
+import_upstream.sh - Import HomeBank from upstream
+
+=head1 SYNOPSIS
+
+    ./maint/import_upstream.sh BRANCH
+
+    # import the latest release on the 5.1.x branch
+    ./maint/import_upstream.sh 5.1.x
+
+=head1 DESCRIPTION
+
+This script downloads the latest HomeBank release on a given branch and adds
+that release to the local C<upstream> branch.
+
+=cut
+
+export GIT_AUTHOR_NAME='Maxime Doyen'
+export GIT_AUTHOR_EMAIL='homebank@free.fr'
+
+branch_git='upstream'
+branch_bzr=$1
+shift
+
+if [ -z "$branch_bzr" ]
+then
+    echo >&2 "$0: Must specify homebank branch (e.g. \"5.1.x\")"
+    exit 1
+fi
+
+set -e
+
+# download homebank
+cleanup='rm -rf "$branch_bzr"'
+eval "$cleanup"
+trap "$cleanup" EXIT
+bzr branch "lp:homebank/$branch_bzr" "$branch_bzr"
+
+# determine version
+hb_version=$(perl <"$branch_bzr/src/homebank.h" -ne 's/#define HB_VERSION\s+"(.*)"/$1/ && print')
+if [ -z "$hb_version" ]
+then
+    echo >&2 "$0: Cannot determine homebank version"
+    exit 1
+fi
+
+cp .gitignore "$branch_bzr/"
+
+# commit new version of homebank
+git add "$branch_bzr"
+tree_ref=$(git write-tree --prefix="$branch_bzr/")
+git reset "$branch_bzr"
+parent_ref=$(git rev-parse "$branch_git")
+commit_ref=$(git commit-tree -m "import homebank-$hb_version" -p $parent_ref $tree_ref)
+
+# update branch
+git branch -f "$branch_git" $commit_ref
+
This page took 0.024477 seconds and 4 git commands to generate.