add script to automate importing upstream
[chaz/homebank] / maint / import_upstream.sh
1 #!/bin/sh
2
3 : <<'=cut'
4 =pod
5
6 =head1 NAME
7
8 import_upstream.sh - Import HomeBank from upstream
9
10 =head1 SYNOPSIS
11
12 ./maint/import_upstream.sh BRANCH
13
14 # import the latest release on the 5.1.x branch
15 ./maint/import_upstream.sh 5.1.x
16
17 =head1 DESCRIPTION
18
19 This script downloads the latest HomeBank release on a given branch and adds
20 that release to the local C<upstream> branch.
21
22 =cut
23
24 export GIT_AUTHOR_NAME='Maxime Doyen'
25 export GIT_AUTHOR_EMAIL='homebank@free.fr'
26
27 branch_git='upstream'
28 branch_bzr=$1
29 shift
30
31 if [ -z "$branch_bzr" ]
32 then
33 echo >&2 "$0: Must specify homebank branch (e.g. \"5.1.x\")"
34 exit 1
35 fi
36
37 set -e
38
39 # download homebank
40 cleanup='rm -rf "$branch_bzr"'
41 eval "$cleanup"
42 trap "$cleanup" EXIT
43 bzr branch "lp:homebank/$branch_bzr" "$branch_bzr"
44
45 # determine version
46 hb_version=$(perl <"$branch_bzr/src/homebank.h" -ne 's/#define HB_VERSION\s+"(.*)"/$1/ && print')
47 if [ -z "$hb_version" ]
48 then
49 echo >&2 "$0: Cannot determine homebank version"
50 exit 1
51 fi
52
53 cp .gitignore "$branch_bzr/"
54
55 # commit new version of homebank
56 git add "$branch_bzr"
57 tree_ref=$(git write-tree --prefix="$branch_bzr/")
58 git reset "$branch_bzr"
59 parent_ref=$(git rev-parse "$branch_git")
60 commit_ref=$(git commit-tree -m "import homebank-$hb_version" -p $parent_ref $tree_ref)
61
62 # update branch
63 git branch -f "$branch_git" $commit_ref
64
This page took 0.038792 seconds and 4 git commands to generate.