t / t9829-git-p4-jobs.shon commit built-in rebase --autostash: leave the current branch alone if possible (176f5d9)
   1#!/bin/sh
   2
   3test_description='git p4 retrieve job info'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11test_expect_success 'add p4 jobs' '
  12        (
  13                p4_add_job TESTJOB-A &&
  14                p4_add_job TESTJOB-B
  15        )
  16'
  17
  18test_expect_success 'add p4 files' '
  19        client_view "//depot/... //client/..." &&
  20        (
  21                cd "$cli" &&
  22                >file1 &&
  23                p4 add file1 &&
  24                p4 submit -d "Add file 1"
  25        )
  26'
  27
  28test_expect_success 'check log message of changelist with no jobs' '
  29        client_view "//depot/... //client/..." &&
  30        test_when_finished cleanup_git &&
  31        (
  32                cd "$git" &&
  33                git init . &&
  34                git p4 clone --use-client-spec --destination="$git" //depot@all &&
  35                cat >expect <<-\EOF &&
  36                Add file 1
  37                [git-p4: depot-paths = "//depot/": change = 1]
  38
  39                EOF
  40                git log --format=%B >actual &&
  41                test_cmp expect actual
  42        )
  43'
  44
  45test_expect_success 'add TESTJOB-A to change 1' '
  46        (
  47                cd "$cli" &&
  48                p4 fix -c 1 TESTJOB-A
  49        )
  50'
  51
  52test_expect_success 'check log message of changelist with one job' '
  53        client_view "//depot/... //client/..." &&
  54        test_when_finished cleanup_git &&
  55        (
  56                cd "$git" &&
  57                git init . &&
  58                git p4 clone --use-client-spec --destination="$git" //depot@all &&
  59                cat >expect <<-\EOF &&
  60                Add file 1
  61                Jobs: TESTJOB-A
  62                [git-p4: depot-paths = "//depot/": change = 1]
  63
  64                EOF
  65                git log --format=%B >actual &&
  66                test_cmp expect actual
  67        )
  68'
  69
  70test_expect_success 'add TESTJOB-B to change 1' '
  71        (
  72                cd "$cli" &&
  73                p4 fix -c 1 TESTJOB-B
  74        )
  75'
  76
  77test_expect_success 'check log message of changelist with more jobs' '
  78        client_view "//depot/... //client/..." &&
  79        test_when_finished cleanup_git &&
  80        (
  81                cd "$git" &&
  82                git init . &&
  83                git p4 clone --use-client-spec --destination="$git" //depot@all &&
  84                cat >expect <<-\EOF &&
  85                Add file 1
  86                Jobs: TESTJOB-A TESTJOB-B
  87                [git-p4: depot-paths = "//depot/": change = 1]
  88
  89                EOF
  90                git log --format=%B >actual &&
  91                test_cmp expect actual
  92        )
  93'
  94
  95test_expect_success 'kill p4d' '
  96        kill_p4d
  97'
  98
  99test_done