2d7dc27f31287e817295d92ec835035622dfd930
   1#!/bin/sh
   2
   3test_description='git p4 submit'
   4
   5. ./lib-git-p4.sh
   6
   7test_expect_success 'start p4d' '
   8        start_p4d
   9'
  10
  11test_expect_success 'init depot' '
  12        (
  13                cd "$cli" &&
  14                echo file1 >file1 &&
  15                p4 add file1 &&
  16                p4 submit -d "change 1"
  17        )
  18'
  19
  20test_expect_success 'submit with no client dir' '
  21        test_when_finished cleanup_git &&
  22        git p4 clone --dest="$git" //depot &&
  23        (
  24                cd "$git" &&
  25                echo file2 >file2 &&
  26                git add file2 &&
  27                git commit -m "git commit 2" &&
  28                rm -rf "$cli" &&
  29                git config git-p4.skipSubmitEdit true &&
  30                git p4 submit
  31        ) &&
  32        (
  33                cd "$cli" &&
  34                test_path_is_file file1 &&
  35                test_path_is_file file2
  36        )
  37'
  38
  39# make two commits, but tell it to apply only from HEAD^
  40test_expect_success 'submit --origin' '
  41        test_when_finished cleanup_git &&
  42        git p4 clone --dest="$git" //depot &&
  43        (
  44                cd "$git" &&
  45                test_commit "file3" &&
  46                test_commit "file4" &&
  47                git config git-p4.skipSubmitEdit true &&
  48                git p4 submit --origin=HEAD^
  49        ) &&
  50        (
  51                cd "$cli" &&
  52                test_path_is_missing "file3.t" &&
  53                test_path_is_file "file4.t"
  54        )
  55'
  56
  57test_expect_success 'submit with allowSubmit' '
  58        test_when_finished cleanup_git &&
  59        git p4 clone --dest="$git" //depot &&
  60        (
  61                cd "$git" &&
  62                test_commit "file5" &&
  63                git config git-p4.skipSubmitEdit true &&
  64                git config git-p4.allowSubmit "nobranch" &&
  65                test_must_fail git p4 submit &&
  66                git config git-p4.allowSubmit "nobranch,master" &&
  67                git p4 submit
  68        )
  69'
  70
  71test_expect_success 'submit with master branch name from argv' '
  72        test_when_finished cleanup_git &&
  73        git p4 clone --dest="$git" //depot &&
  74        (
  75                cd "$git" &&
  76                test_commit "file6" &&
  77                git config git-p4.skipSubmitEdit true &&
  78                test_must_fail git p4 submit nobranch &&
  79                git branch otherbranch &&
  80                git reset --hard HEAD^ &&
  81                test_commit "file7" &&
  82                git p4 submit otherbranch
  83        ) &&
  84        (
  85                cd "$cli" &&
  86                test_path_is_file "file6.t" &&
  87                test_path_is_missing "file7.t"
  88        )
  89'
  90
  91test_expect_success 'kill p4d' '
  92        kill_p4d
  93'
  94
  95test_done