diff options
author | Jay Conrod <jayconrod@google.com> | 2021-03-31 14:29:13 -0400 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2021-04-09 18:19:42 +0000 |
commit | 952187af12485eb665ae122f6d0bdb36e4a11ed7 (patch) | |
tree | a47c02ec6ceda38fad664ea84ee691664bf4c22f /src/cmd/vendor | |
parent | fcf8a6640b1bfb2444749b558f926321841922fa (diff) | |
download | go-952187af12485eb665ae122f6d0bdb36e4a11ed7.tar.gz go-952187af12485eb665ae122f6d0bdb36e4a11ed7.zip |
cmd/go: upgrade and vendor golang.org/x/mod
To pull in CL 301089.
For #40357
Change-Id: I8aa9bc8d7a75f804adc7982adaaa1c926b43d0ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/306333
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/vendor')
-rw-r--r-- | src/cmd/vendor/golang.org/x/mod/modfile/rule.go | 51 | ||||
-rw-r--r-- | src/cmd/vendor/modules.txt | 2 |
2 files changed, 42 insertions, 11 deletions
diff --git a/src/cmd/vendor/golang.org/x/mod/modfile/rule.go b/src/cmd/vendor/golang.org/x/mod/modfile/rule.go index f8c9384985..3f603fa60f 100644 --- a/src/cmd/vendor/golang.org/x/mod/modfile/rule.go +++ b/src/cmd/vendor/golang.org/x/mod/modfile/rule.go @@ -47,8 +47,9 @@ type File struct { // A Module is the module statement. type Module struct { - Mod module.Version - Syntax *Line + Mod module.Version + Deprecated string + Syntax *Line } // A Go is the go statement. @@ -131,8 +132,15 @@ var dontFixRetract VersionFixer = func(_, vers string) (string, error) { return vers, nil } -// Parse parses the data, reported in errors as being from file, -// into a File struct. It applies fix, if non-nil, to canonicalize all module versions found. +// Parse parses and returns a go.mod file. +// +// file is the name of the file, used in positions and errors. +// +// data is the content of the file. +// +// fix is an optional function that canonicalizes module versions. +// If fix is nil, all module versions must be canonical (module.CanonicalVersion +// must return the same string). func Parse(file string, data []byte, fix VersionFixer) (*File, error) { return parseToFile(file, data, fix, true) } @@ -271,7 +279,11 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a errorf("repeated module statement") return } - f.Module = &Module{Syntax: line} + deprecated := parseDeprecation(block, line) + f.Module = &Module{ + Syntax: line, + Deprecated: deprecated, + } if len(args) != 1 { errorf("usage: module module/path") return @@ -385,7 +397,7 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a }) case "retract": - rationale := parseRetractRationale(block, line) + rationale := parseDirectiveComment(block, line) vi, err := parseVersionInterval(verb, "", &args, dontFixRetract) if err != nil { if strict { @@ -612,10 +624,29 @@ func parseString(s *string) (string, error) { return t, nil } -// parseRetractRationale extracts the rationale for a retract directive from the -// surrounding comments. If the line does not have comments and is part of a -// block that does have comments, the block's comments are used. -func parseRetractRationale(block *LineBlock, line *Line) string { +var deprecatedRE = lazyregexp.New(`(?s)(?:^|\n\n)Deprecated: *(.*?)(?:$|\n\n)`) + +// parseDeprecation extracts the text of comments on a "module" directive and +// extracts a deprecation message from that. +// +// A deprecation message is contained in a paragraph within a block of comments +// that starts with "Deprecated:" (case sensitive). The message runs until the +// end of the paragraph and does not include the "Deprecated:" prefix. If the +// comment block has multiple paragraphs that start with "Deprecated:", +// parseDeprecation returns the message from the first. +func parseDeprecation(block *LineBlock, line *Line) string { + text := parseDirectiveComment(block, line) + m := deprecatedRE.FindStringSubmatch(text) + if m == nil { + return "" + } + return m[1] +} + +// parseDirectiveComment extracts the text of comments on a directive. +// If the directive's line does not have comments and is part of a block that +// does have comments, the block's comments are used. +func parseDirectiveComment(block *LineBlock, line *Line) string { comments := line.Comment() if block != nil && len(comments.Before) == 0 && len(comments.Suffix) == 0 { comments = block.Comment() diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index 4a128c7933..80ccb2bf24 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -27,7 +27,7 @@ golang.org/x/arch/x86/x86asm ## explicit golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 -# golang.org/x/mod v0.4.3-0.20210323215154-1cc8812c1740 +# golang.org/x/mod v0.4.3-0.20210409134425-858fdbee9c24 ## explicit golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile |