t / t9804-git-p4-label.shon commit Merge branch 'bn/http-cookiefile-config' (459000e)
   1#!/bin/sh
   2
   3test_description='git p4 label tests'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11# Basic p4 label tests.
  12#
  13# Note: can't have more than one label per commit - others
  14# are silently discarded.
  15#
  16test_expect_success 'basic p4 labels' '
  17        test_when_finished cleanup_git &&
  18        (
  19                cd "$cli" &&
  20                mkdir -p main &&
  21
  22                echo f1 >main/f1 &&
  23                p4 add main/f1 &&
  24                p4 submit -d "main/f1" &&
  25
  26                echo f2 >main/f2 &&
  27                p4 add main/f2 &&
  28                p4 submit -d "main/f2" &&
  29
  30                echo f3 >main/file_with_\$metachar &&
  31                p4 add main/file_with_\$metachar &&
  32                p4 submit -d "file with metachar" &&
  33
  34                p4 tag -l tag_f1_only main/f1 &&
  35                p4 tag -l tag_with\$_shell_char main/... &&
  36
  37                echo f4 >main/f4 &&
  38                p4 add main/f4 &&
  39                p4 submit -d "main/f4" &&
  40
  41                p4 label -i <<-EOF &&
  42                Label: long_label
  43                Description:
  44                   A Label first line
  45                   A Label second line
  46                View:   //depot/...
  47                EOF
  48
  49                p4 tag -l long_label ... &&
  50
  51                p4 labels ... &&
  52
  53                git p4 clone --dest="$git" --detect-labels //depot@all &&
  54                cd "$git" &&
  55
  56                git tag &&
  57                git tag >taglist &&
  58                test_line_count = 3 taglist &&
  59
  60                cd main &&
  61                git checkout tag_tag_f1_only &&
  62                ! test -f f2 &&
  63                git checkout tag_tag_with\$_shell_char &&
  64                test -f f1 && test -f f2 && test -f file_with_\$metachar &&
  65
  66                git show tag_long_label | grep -q "A Label second line"
  67        )
  68'
  69
  70# Test some label corner cases:
  71#
  72# - two tags on the same file; both should be available
  73# - a tag that is only on one file; this kind of tag
  74#   cannot be imported (at least not easily).
  75
  76test_expect_failure 'two labels on the same changelist' '
  77        test_when_finished cleanup_git &&
  78        (
  79                cd "$cli" &&
  80                mkdir -p main &&
  81
  82                p4 edit main/f1 main/f2 &&
  83                echo "hello world" >main/f1 &&
  84                echo "not in the tag" >main/f2 &&
  85                p4 submit -d "main/f[12]: testing two labels" &&
  86
  87                p4 tag -l tag_f1_1 main/... &&
  88                p4 tag -l tag_f1_2 main/... &&
  89
  90                p4 labels ... &&
  91
  92                git p4 clone --dest="$git" --detect-labels //depot@all &&
  93                cd "$git" &&
  94
  95                git tag | grep tag_f1 &&
  96                git tag | grep -q tag_f1_1 &&
  97                git tag | grep -q tag_f1_2 &&
  98
  99                cd main &&
 100
 101                git checkout tag_tag_f1_1 &&
 102                ls &&
 103                test -f f1 &&
 104
 105                git checkout tag_tag_f1_2 &&
 106                ls &&
 107                test -f f1
 108        )
 109'
 110
 111test_expect_success 'kill p4d' '
 112        kill_p4d
 113'
 114
 115test_done