github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_upgrade_patch.txt (about)

     1  env GO111MODULE=on
     2  [short] skip
     3  
     4  # Initially, we are at v1.0.0 for all dependencies.
     5  cp go.mod go.mod.orig
     6  go list -m all
     7  stdout '^patch.example.com/direct v1.0.0'
     8  stdout '^patch.example.com/indirect v1.0.0'
     9  ! stdout '^patch.example.com/depofdirectpatch'
    10  
    11  # get -u=patch, with no arguments, should patch-update all dependencies
    12  # of the package in the current directory, pulling in transitive dependencies
    13  # and also patching those.
    14  cp go.mod.orig go.mod
    15  go get -d -u=patch
    16  go list -m all
    17  stdout '^patch.example.com/direct v1.0.1'
    18  stdout '^patch.example.com/indirect v1.0.1'
    19  stdout '^patch.example.com/depofdirectpatch v1.0.0'
    20  
    21  # 'get all@patch' should be equivalent to 'get -u=patch all'
    22  cp go.mod.orig go.mod
    23  go get -d all@patch
    24  go list -m all
    25  stdout '^patch.example.com/direct v1.0.1'
    26  stdout '^patch.example.com/indirect v1.0.1'
    27  stdout '^patch.example.com/depofdirectpatch v1.0.0'
    28  
    29  # Requesting the direct dependency with -u=patch but without an explicit version
    30  # should patch-update it and its dependencies.
    31  cp go.mod.orig go.mod
    32  go get -d -u=patch patch.example.com/direct
    33  go list -m all
    34  stdout '^patch.example.com/direct v1.0.1'
    35  stdout '^patch.example.com/indirect v1.0.1'
    36  stdout '^patch.example.com/depofdirectpatch v1.0.0'
    37  
    38  # Requesting only the indirect dependency should not update the direct one.
    39  cp go.mod.orig go.mod
    40  go get -d -u=patch patch.example.com/indirect
    41  go list -m all
    42  stdout '^patch.example.com/direct v1.0.0'
    43  stdout '^patch.example.com/indirect v1.0.1'
    44  ! stdout '^patch.example.com/depofdirectpatch'
    45  
    46  # @patch should apply only to the specific module,
    47  # but the result must reflect its upgraded requirements.
    48  cp go.mod.orig go.mod
    49  go get -d patch.example.com/direct@patch
    50  go list -m all
    51  stdout '^patch.example.com/direct v1.0.1'
    52  stdout '^patch.example.com/indirect v1.0.0'
    53  stdout '^patch.example.com/depofdirectpatch v1.0.0'
    54  
    55  # An explicit @patch should override a general -u.
    56  cp go.mod.orig go.mod
    57  go get -d -u patch.example.com/direct@patch
    58  go list -m all
    59  stdout '^patch.example.com/direct v1.0.1'
    60  stdout '^patch.example.com/indirect v1.1.0'
    61  stdout '^patch.example.com/depofdirectpatch v1.0.0'
    62  
    63  # An explicit @latest should override a general -u=patch.
    64  cp go.mod.orig go.mod
    65  go get -d -u=patch patch.example.com/direct@latest
    66  go list -m all
    67  stdout '^patch.example.com/direct v1.1.0'
    68  stdout '^patch.example.com/indirect v1.0.1'
    69  ! stdout '^patch.example.com/depofdirectpatch'
    70  
    71  # Standard-library packages cannot be upgraded explicitly.
    72  cp go.mod.orig go.mod
    73  ! go get cmd/vet@patch
    74  stderr 'cannot use pattern .* with explicit version'
    75  
    76  # However, standard-library packages without explicit versions are fine.
    77  go get -d -u=patch -d cmd/go
    78  
    79  # We can upgrade to a new version of a module with no root package.
    80  go get -d example.com/noroot@v1.0.0
    81  go list -m all
    82  stdout '^example.com/noroot v1.0.0$'
    83  go get -d example.com/noroot@patch
    84  go list -m all
    85  stdout '^example.com/noroot v1.0.1$'
    86  
    87  -- go.mod --
    88  module x
    89  
    90  require patch.example.com/direct v1.0.0
    91  
    92  -- main.go --
    93  package x
    94  import _ "patch.example.com/direct"