File: pull-ours.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 (90 lines) | stat: -rw-r--r-- 1,560 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
#!/usr/bin/env bash

set -e

source test/setup

use Test::More

clone-foo-and-bar

subrepo-clone-bar-into-foo

note "Pull - Conflict - Use ours - Push"

#
# When you perform rebase ours/theirs are reversed, so this test case will
# test using local change (ours) although in the step below
# we actually use git checkout --theirs to accomplish this
#

(
  cd "$OWNER/bar"
  add-new-files Bar2
  git push
) &> /dev/null || die

(
  cd "$OWNER/foo"
  git subrepo pull bar
  modify-files-ex bar/Bar2
  cat bar/Bar2
  git push
) &> /dev/null || die

(
  cd "$OWNER/bar"
  modify-files-ex Bar2
  git push
) &> /dev/null || die

before=$(date -r "$OWNER/foo/Foo" '+%s')

(
  cd "$OWNER/foo"
  git subrepo pull bar || {
      cd .git/tmp/subrepo/bar
      git checkout --ours Bar2
      git add Bar2
      git commit --file ../../../../.git/worktrees/bar/MERGE_MSG
      cd ../../../..
      git subrepo commit bar
      git subrepo clean bar
  }
) &> /dev/null || die

sleep 1
after=$(date -r "$OWNER/foo/Foo" '+%s')

is "$before" "$after" \
  "No modification on Foo"

test-exists \
  "$OWNER/foo/bar/Bar2" \
  "$OWNER/bar/Bar2" \

is "$(cat "$OWNER/foo/bar/Bar2")" \
  "new file Bar2"$'\n'"bar/Bar2" \
  "The readme file in the mainrepo is ours"

(
  cd "$OWNER/foo"
  git subrepo push bar
) &> /dev/null || die

(
  cd "$OWNER/bar"
  git pull
) &> /dev/null || die

test-exists \
  "$OWNER/foo/bar/Bar2" \
  "$OWNER/bar/Bar2" \

is "$(cat "$OWNER/bar/Bar2")" \
  "new file Bar2"$'\n'"bar/Bar2" \
  "The readme file in the subrepo is ours"

done_testing

teardown