aboutsummaryrefslogtreecommitdiff
path: root/tests/rep-fetch-git-commit.testscript
blob: fd406e131e42adffdcdd585da9f52654330232ac (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# file      : tests/rep-fetch-git-commit.testscript
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

+git clone "$rep_git/state0/style-basic.git" 2>! &style-basic/***
+git clone "$rep_git/state0/libbar.git"      2>! &libbar/***

: unadvertised
:
{
  +git -C ../style-basic log '--pretty=format:%H' --all --grep='README' | \
   set commit

  : no-refname
  :
  : Here we also test that a commit can be specified without leading '@'.
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#$commit";

    if ($git_protocol == 'https-dumb')
      warn = "$warn_repo_hist$reason_dumb$warn_dumb"
    elif ($git_protocol != 'https-smart-unadv')
      warn = "$warn_repo_hist$reason_unadv"
    end;

    $* 2>>~"%EOE%"
      %fetching git:.+style-basic#$commit%
      %querying .+style-basic\.git%?
      %fetching from .+style-basic\.git%
      $warn
      1 package\(s\) in 1 repository\(s\)
      EOE
  }

  : refname
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit";

    if ($git_protocol == 'https-dumb')
      warn = "$warn_ref_hist$reason_dumb$warn_dumb"
    elif ($git_protocol != 'https-smart-unadv')
      warn = "$warn_ref_hist$reason_unadv"
    end;

    $* 2>>~"%EOE%"
      %fetching git:.+style-basic#stable@$commit%
      %querying .+style-basic\.git%?
      %fetching from .+style-basic\.git%
      $warn
      1 package\(s\) in 1 repository\(s\)
      EOE
  }
}

: advertised
:
{
  +git -C ../style-basic log '--pretty=format:%H' --all --grep='INSTALL' | \
   set commit

  +if ($git_protocol == 'https-dumb')
     warn = "$warn_ref_hist$reason_dumb$warn_dumb"
   end

  : no-refname
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#@$commit";

    $* 2>>~"%EOE%"
      %fetching git:.+style-basic#@$commit%
      %querying .+style-basic\.git%?
      %fetching from .+style-basic.\git%
      %querying .+style-basic\.git%?
      $warn
      1 package\(s\) in 1 repository\(s\)
      EOE
  }

  : refname
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/style-basic.git#stable@$commit";

    $* 2>>~"%EOE%"
      %fetching git:.+style-basic#stable@$commit%
      %querying .+style-basic\.git%?
      %fetching from .+style-basic\.git%
      %querying .+style-basic\.git%?
      $warn
      1 package\(s\) in 1 repository\(s\)
      EOE
  }
}

: peeled
:
{
  +git -C ../libbar log '--pretty=format:%H' --all --grep='Create' | \
   set commit

  : remap
  :
  : Test that the commit id is properly remapped back to the advertised tag
  : reference.
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/libbar.git#@$commit";

    $* 2>>~"%EOE%"
      %fetching git:.+libbar#@$commit%
      %.+
      EOE
  }

  : peel
  :
  : Test that the tag reference is properly peeled into the commit id.
  :
  {
    $clone_root_cfg && $rep_add "$rep/state0/libbar.git#v1.0.0,-$commit";

    $* 2>>~%EOE%
      %.+
      0 package(s) in 1 repository(s)
      EOE
  }
}