1test_description='git-p4 p4 label tests'
23
. ./lib-git-p4.sh
45
test_expect_success 'start p4d' '
6start_p4d
7'
89
# Basic p4 label tests.
10#
11# Note: can't have more than one label per commit - others
12# are silently discarded.
13#
14test_expect_success 'basic p4 labels' '
15test_when_finished cleanup_git &&
16(
17cd "$cli" &&
18mkdir -p main &&
1920
echo f1 >main/f1 &&
21p4 add main/f1 &&
22p4 submit -d "main/f1" &&
2324
echo f2 >main/f2 &&
25p4 add main/f2 &&
26p4 submit -d "main/f2" &&
2728
echo f3 >main/file_with_\$metachar &&
29p4 add main/file_with_\$metachar &&
30p4 submit -d "file with metachar" &&
3132
p4 tag -l tag_f1_only main/f1 &&
33p4 tag -l tag_with\$_shell_char main/... &&
3435
echo f4 >main/f4 &&
36p4 add main/f4 &&
37p4 submit -d "main/f4" &&
3839
p4 label -i <<-EOF &&
40Label: long_label
41Description:
42A Label first line
43A Label second line
44View: //depot/...
45EOF
4647
p4 tag -l long_label ... &&
4849
p4 labels ... &&
5051
"$GITP4" clone --dest="$git" --detect-labels //depot@all &&
52cd "$git" &&
5354
git tag &&
55git tag >taglist &&
56test_line_count = 3 taglist &&
5758
cd main &&
59git checkout tag_tag_f1_only &&
60! test -f f2 &&
61git checkout tag_tag_with\$_shell_char &&
62test -f f1 && test -f f2 && test -f file_with_\$metachar &&
6364
git show tag_long_label | grep -q "A Label second line"
65)
66'
6768
# Test some label corner cases:
69#
70# - two tags on the same file; both should be available
71# - a tag that is only on one file; this kind of tag
72# cannot be imported (at least not easily).
7374
test_expect_failure 'two labels on the same changelist' '
75test_when_finished cleanup_git &&
76(
77cd "$cli" &&
78mkdir -p main &&
7980
p4 edit main/f1 main/f2 &&
81echo "hello world" >main/f1 &&
82echo "not in the tag" >main/f2 &&
83p4 submit -d "main/f[12]: testing two labels" &&
8485
p4 tag -l tag_f1_1 main/... &&
86p4 tag -l tag_f1_2 main/... &&
8788
p4 labels ... &&
8990
"$GITP4" clone --dest="$git" --detect-labels //depot@all &&
91cd "$git" &&
9293
git tag | grep tag_f1 &&
94git tag | grep -q tag_f1_1 &&
95git tag | grep -q tag_f1_2 &&
9697
cd main &&
9899
git checkout tag_tag_f1_1 &&
100ls &&
101test -f f1 &&
102103
git checkout tag_tag_f1_2 &&
104ls &&
105test -f f1
106)
107'
108109
test_expect_success 'kill p4d' '
110kill_p4d
111'
112113
test_done