summaryrefslogtreecommitdiff
path: root/tests.branching/merge-conflict-stratum.script
blob: 8f0a3170cfbc3287189e8bd79c0a7b388b25193b (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
#!/bin/sh
# Copyright (C) 2012  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.

# Simple merge conflict handling test.

set -eu

# Disable test on versions of Python before 2.7.
if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null
then
    cat "$SRCDIR/tests.branching/merge-conflict-stratum.stdout"
    cat "$SRCDIR/tests.branching/merge-conflict-stratum.stderr" >&2
    exit 1
fi

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

# Create stable branch to merge TO
"$SRCDIR/scripts/test-morph" branch baserock:morphs test/stable
cd test/stable/baserock:morphs
git push --quiet origin test/stable

# Create feature branch to merge FROM
"$SRCDIR/scripts/test-morph" branch baserock:morphs test/feature test/stable

# Need 2 chunks!

# Make a change in TO
cd "$DATADIR/workspace/test/stable"
"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum
cd baserock:morphs
cat <<EOF > "hello-stratum.morph"
{
    "name": "hello-stratum",
    "kind": "stratum",
    "chunks": [
        {
            "name": "hello-runtime",
            "repo": "baserock:hello",
            "ref": "master",
            "morph": "hello",
            "build-depends": []
        },
        {
            "name": "hello-devel",
            "repo": "baserock:hello",
            "ref": "master",
            "morph": "hello",
            "build-depends": []
        }
    ]
}
EOF
git commit --quiet --all -m "Split up 'hello' chunk into runtime and devel"

# Make a change in FROM that isn't very mergable
cd "$DATADIR/workspace/test/feature"
"$SRCDIR/scripts/test-morph" edit hello-system hello-stratum
cd baserock:morphs
cat <<EOF > "hello-stratum.morph"
{
    "name": "hello-stratum",
    "kind": "stratum",
    "chunks": [
        {
            "name": "hello-devel",
            "repo": "baserock:hello",
            "ref": "master",
            "morph": "hello",
            "build-depends": []
        },
        {
            "name": "hello-runtime",
            "repo": "baserock:hello",
            "ref": "master",
            "morph": "hello",
            "build-depends": []
        }
    ]
}
EOF
git commit --quiet --all -m "Split up 'hello' chunk into devel and runtime"

# Merge changes from test/feature to test/stable
cd "$DATADIR/workspace/test/stable"
"$SRCDIR/scripts/test-morph" merge test/feature

# Check results: changes to 'hello' should have been merged back to
# test/stable.
cd baserock:hello
[ -e newfile.txt ]

# Make sure all changes are committed and to the correct branch ('hello'
# was built from 'master' before branching, so the changes should be
# merged back to 'master').
git status --short
[ $(git rev-parse master) = $(git rev-parse HEAD) ]

# Changes here should be on test/stable.
cd ../baserock:morphs
git status --short
[ $(git rev-parse test/stable) = $(git rev-parse HEAD) ]

# Make sure all refs to the merged branch have gone.
! grep "\"ref\": \"test/feature\"" *.morph