summaryrefslogtreecommitdiff
path: root/tests/update-gits-chunk.script
blob: 49072419b4b19c99a1ec60156b915a198f6940f7 (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
40
41
42
43
#!/bin/bash
#
# Copyright (C) 2012-2013  Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


## Test that 'morph update-gits' updates every chunk listed on the
## command line.

set -eu

# Local repos do not get cached, so we need to fake some remote repositories
git daemon --port=9419 --pid-file="$DATADIR/git.pid" --reuseaddr \
    --export-all --base-path="$DATADIR" 2> /dev/null &
trap 'kill $(cat "$DATADIR/git.pid")' INT TERM ERR
REPO_ALIAS='test=git://127.0.0.1:9419/%s#git://127.0.0.1:9419/%s'

# Create an empty commit in a chunk repository
cd "$DATADIR/chunk-repo"
git checkout --quiet farrokh
git commit --quiet --allow-empty --allow-empty-message -m ""
NEWREF="$(git rev-parse --verify farrokh)"

"$SRCDIR/scripts/test-morph" --repo-alias=$REPO_ALIAS update-gits \
    test:chunk-repo farrokh hello

kill $(cat "$DATADIR/git.pid")

# Check the top commit of the cached repo's farrokh branch
cd "$DATADIR/cache/gits/"*chunk?repo*
test "$(git rev-parse --verify refs/heads/farrokh)" = "$NEWREF"