summaryrefslogtreecommitdiff
path: root/tests.branching/tag-works-with-multiple-morphs-repos.script
blob: 94cd01dcf8846c7cb97b1ca706f10dc376956f06 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh
#
# 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.


## Check that "morph tag" works if morphologies are spread across multiple
## repositories. In this case, it should copy all petrified morphologies
## into the branch root repository and only create the tag there.

set -eu

# Make sure the commits always have the same SHA1s.
. "$SRCDIR/scripts/fix-committer-info"

# Create new directory for repos used in this test.
mkdir -p "$DATADIR/repos"

# Create the first morphs repository.
mkdir "$DATADIR/repos/morphs1"

# Create system morphology in first morphs repository.
cat <<EOF > "$DATADIR/repos/morphs1/test-system.morph"
{
    "name": "test-system",
    "kind": "system",
    "system-kind": "syslinux-disk",
    "arch": "$(uname -m)",
    "disk-size": "1G",
    "strata": [
        {
            "morph": "stratum1",
            "repo": "repos:morphs1",
            "ref": "master"
        },
        {
            "morph": "stratum2",
            "repo": "repos:morphs2",
            "ref": "master"
        }
    ]
}
EOF

# Create stratum that depends on another stratum.
cat <<EOF > "$DATADIR/repos/morphs1/stratum1.morph"
{
    "name": "stratum1",
    "kind": "stratum",
    "build-depends": [
        {
            "morph": "stratum3",
            "repo": "repos:morphs2",
            "ref": "master"
        }
    ]
}
EOF

# Commit all files to the first repository.
scripts/run-git-in "$DATADIR/repos/morphs1" init -q
scripts/run-git-in "$DATADIR/repos/morphs1" add .
scripts/run-git-in "$DATADIR/repos/morphs1" commit -q -m initial

# Create second morphs repository.
mkdir "$DATADIR/repos/morphs2"

# Create two strata in the second repository.
cat <<EOF > "$DATADIR/repos/morphs2/stratum2.morph"
{
    "name": "stratum2",
    "kind": "stratum",
    "build-depends": [
        {
            "morph": "stratum3",
            "repo": "repos:morphs2",
            "ref": "master"
        }
    ]
}
EOF
cat <<EOF > "$DATADIR/repos/morphs2/stratum3.morph"
{
    "name": "stratum3",
    "kind": "stratum"
}
EOF

# Commit all files to the second repository.
"$SRCDIR/scripts/run-git-in" "$DATADIR/repos/morphs2" init -q
"$SRCDIR/scripts/run-git-in" "$DATADIR/repos/morphs2" add .
"$SRCDIR/scripts/run-git-in" "$DATADIR/repos/morphs2" commit -q -m initial

cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init

# Check out the master system branch.
"$SRCDIR/scripts/test-morph" \
    --repo-alias=repos="file://$DATADIR/repos/%s#file://$DATADIR/%s" \
    checkout repos:morphs1 master

# Tag the master system branch.
"$SRCDIR/scripts/test-morph" \
    --repo-alias=repos="file://$DATADIR/repos/%s#file://$DATADIR/%s" \
    tag tag-across-multiple-repos -- -m "create tag"

# Show the tag.
GIT_DIR="$DATADIR/workspace/master/repos:morphs1/.git" \
    git show tag-across-multiple-repos
GIT_DIR="$DATADIR/workspace/master/repos:morphs1/.git" \
    git log --format=fuller -n1 -p --stat tag-across-multiple-repos