Updated control files for adding changelog entries.
[dcp.git] / dcp-update
... / ...
CommitLineData
1#!/bin/bash
2
3set -e
4
5usage() {
6 echo "usage: dcp-update [-Nh] REPODIR"
7}
8
9rungit() {
10 (
11 cd "$td/repo"
12 git "$@"
13 ) || false
14}
15
16defdir=/srv/dcp
17push=y
18
19while [ "${1:0:1}" = - ]; do
20 opt="${1:1}"
21 shift
22 if [ "$opt" = N ]; then
23 push=n
24 elif [ "$opt" = h ]; then
25 usage
26 exit 0
27 else
28 echo "dcp-update: unknown option '$opt'" >&2
29 exit 1
30 fi
31done
32
33if [ $# -lt 1 ]; then
34 usage >&2
35 exit 1
36fi
37
38repodir="$1"
39shift
40if [[ "$repodir" != */* ]]; then
41 repodir="$defdir/${repodir}.git"
42fi
43
44if [ ! -d "$repodir" ]; then
45 echo "dcp-build: could not find $repodir" >&2
46 exit 1
47fi
48
49td="$(mktemp -d /tmp/dcp-XXXXXX)"
50exec >"$td/log" 2>"$td/err"
51dcp-runenv "$repodir" "$td"
52
53lastrev="$(rungit rev-parse HEAD)"
54(cd "$td"; control/update) || false
55rungit checkout master
56newrev="$(rungit rev-parse HEAD)"
57
58echo "update: $lastrev -> $newrev"
59
60if [ "$push" = y ]; then rungit push; fi
61
62rm -rf "$td"