...

Text file src/cmd/go/testdata/script/mod_get_pseudo_prefix.txt

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2env GOPROXY=direct
     3env GOSUMDB=off
     4
     5# Testing that a pseudo-version is based on the semantically-latest
     6# prefixed tag in any commit that is a parent of the commit supplied
     7# to 'go get', when using a repo with go.mod in a sub directory.
     8
     9[short] skip
    10[!git] skip
    11
    12# For this test repository go.mod resides in sub/ (only):
    13#  master is not tagged
    14#  tag v0.2.0 is most recent tag before master
    15#  tag sub/v0.0.10 is most recent tag before v0.2.0
    16#
    17# The pseudo-version is based on sub/v0.0.10, since v0.2.0 doesn't
    18# contain the prefix.
    19go get vcs-test.golang.org/git/prefixtagtests.git/sub
    20go list -m all
    21stdout '^vcs-test.golang.org/git/prefixtagtests.git/sub v0.0.10$'
    22
    23go get -u vcs-test.golang.org/git/prefixtagtests.git/sub@master
    24go list -m all
    25stdout '^vcs-test.golang.org/git/prefixtagtests.git/sub v0.0.11-0\.'
    26
    27-- go.mod --
    28module x
    29
    30go 1.12
    31-- x.go --
    32package x
    33
    34import _ "vcs-test.golang.org/prefixtagtests.git/sub"
    35-- gen_prefixtagtests.sh --
    36#!/bin/bash
    37
    38# This is not part of the test.
    39# Run this to generate and update the repository on vcs-test.golang.org.
    40
    41set -euo pipefail
    42cd "$(dirname "$0")"
    43rm -rf prefixtagtests
    44mkdir prefixtagtests
    45cd prefixtagtests
    46
    47git init
    48mkdir sub
    49echo module vcs-test.golang.org/git/prefixtagtests.git/sub >sub/go.mod
    50echo package sub >sub/sub.go
    51git add sub
    52git commit -m 'create module sub'
    53for i in v0.1.0 sub/v0.0.9 sub/v0.0.10 v0.2.0; do
    54  echo $i >status
    55  git add status
    56  git commit -m $i
    57  git tag $i
    58done
    59echo 'after last tag' >status
    60git add status
    61git commit -m 'after last tag'
    62
    63zip -r ../prefixtagtests.zip .
    64gsutil cp ../prefixtagtests.zip gs://vcs-test/git/prefixtagtests.zip

View as plain text