File: issue96.t

package info (click to toggle)
git-subrepo 0.4.9-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,552 kB
  • sloc: sh: 7,074; makefile: 273; perl: 226
file content (96 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

set -e

source test/setup

use Test::More

    cd "$TMP"

    # Make two new repos
    (
        mkdir host sub
        git init host
        git init sub
    ) > /dev/null

    # Initialize host repo
    (
        cd host
        touch host
        git add host
        git commit -m "host initial commit"
    ) > /dev/null

    # Initialize sub repo
    (
        cd sub
        git init
        touch subrepo
        git add subrepo
        git commit -m "subrepo initial commit"
    ) > /dev/null

    # Make sub a subrepo of host
    (
        cd host
        git subrepo clone ../sub sub
    ) > /dev/null

    # Commit some changes to the host repo
    (
        cd host
        touch feature
        git add feature
        git commit -m "feature added"
    ) &> /dev/null

    # Commit directly to subrepo
    (
        cd sub
        echo "direct change in sub" >> subrepo
        git commit -a -m "direct change in sub"
    ) > /dev/null

    # Pull subrepo changes
    (
        cd host
        git subrepo pull sub
    ) > /dev/null

    # Commit directly to subrepo
    (
        cd sub
        echo "another direct change in sub" >> subrepo
        git commit -a -m "another direct change in sub"
        git checkout -b temp # otherwise push to master will fail
    ) &> /dev/null

    # Commit to host/sub
    (
        cd host
        echo "change from host" >> sub/subrepo-host
        git add sub/subrepo-host
        git commit -m "change from host"
    ) > /dev/null

    # Pull subrepo changes
    # expected: successful pull without conflicts
    is "$(
            cd host
            git subrepo pull sub
    )" \
        "Subrepo 'sub' pulled from '../sub' ($DEFAULTBRANCH)."

    # Push subrepo changes
    # expected: successful push without conflicts
    is "$(
            cd host
            git subrepo push sub -b "${DEFAULTBRANCH}" -u
    )" \
       "Subrepo 'sub' pushed to '../sub' ($DEFAULTBRANCH)."

done_testing 2

teardown