зеркало из https://github.com/golang/build.git
relnote: CheckAPIFile: look in right directory
Have CheckAPIFile look for corresponding release note files in the directory doc/next/*stdlib/*minor. Previously, it was looking in doc/next. For golang/go#64169. Change-Id: I40fa31f0e95885648536ce74aa070f9f7fdf692b Reviewed-on: https://go-review.googlesource.com/c/build/+/560295 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Родитель
3723b26e8a
Коммит
3ee44a0927
|
@ -381,7 +381,9 @@ func GroupAPIFeaturesByFile(fs []APIFeature) (map[string][]APIFeature, error) {
|
|||
|
||||
// CheckAPIFile reads the api file at filename in apiFS, and checks the corresponding
|
||||
// release-note files under docFS. It checks that the files exist and that they have
|
||||
// some minimal content (see [CheckFragment]). The docRoot argument is used in error messages.
|
||||
// some minimal content (see [CheckFragment]).
|
||||
// The docRoot argument is the path from the repo or project root to the root of docFS.
|
||||
// It is used only for error messages.
|
||||
func CheckAPIFile(apiFS fs.FS, filename string, docFS fs.FS, docRoot string) error {
|
||||
features, err := parseAPIFile(apiFS, filename)
|
||||
if err != nil {
|
||||
|
@ -396,17 +398,42 @@ func CheckAPIFile(apiFS fs.FS, filename string, docFS fs.FS, docRoot string) err
|
|||
filenames = append(filenames, fn)
|
||||
}
|
||||
slices.Sort(filenames)
|
||||
mcDir, err := minorChangesDir(docFS)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var errs []error
|
||||
for _, fn := range filenames {
|
||||
// Use path.Join for consistency with io/fs pathnames.
|
||||
fn = path.Join(mcDir, fn)
|
||||
// TODO(jba): check that the file mentions each feature?
|
||||
if err := checkFragmentFile(docFS, fn); err != nil {
|
||||
// Use path.Join for consistency with io/fs pathnames.
|
||||
errs = append(errs, fmt.Errorf("%s: %v\nSee doc/README.md for more information.", path.Join(docRoot, fn), err))
|
||||
}
|
||||
}
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
// minorChangesDir returns the unique directory in docFS that corresponds to the
|
||||
// "Minor changes to the standard library" section of the release notes.
|
||||
func minorChangesDir(docFS fs.FS) (string, error) {
|
||||
dirs, err := fs.Glob(docFS, "*stdlib/*minor")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
var bad string
|
||||
if len(dirs) == 0 {
|
||||
bad = "No"
|
||||
} else if len(dirs) > 1 {
|
||||
bad = "More than one"
|
||||
}
|
||||
if bad != "" {
|
||||
return "", fmt.Errorf("%s directory matches *stdlib/*minor.\nThis shouldn't happen; please file a bug at https://go.dev/issues/new.",
|
||||
bad)
|
||||
}
|
||||
return dirs[0], nil
|
||||
}
|
||||
|
||||
func checkFragmentFile(fsys fs.FS, filename string) error {
|
||||
f, err := fsys.Open(filename)
|
||||
if err != nil {
|
||||
|
|
|
@ -252,7 +252,7 @@ func TestCheckAPIFile(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
var got string
|
||||
gotErr := CheckAPIFile(fsys, "api.txt", fsys, "doc/next/*stdlib/*minor")
|
||||
gotErr := CheckAPIFile(fsys, "api.txt", fsys, "doc/next")
|
||||
if gotErr != nil {
|
||||
got = gotErr.Error()
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ errors:
|
|||
-- api.txt --
|
||||
pkg foo, type T #123
|
||||
pkg bar, type T #123
|
||||
-- bar/123.md --
|
||||
-- 7-stdlib/99-minor/bar/123.md --
|
||||
Not a sentence
|
||||
-- want --
|
||||
doc/next/*stdlib/*minor/bar/123.md: File must contain a complete sentence or a TODO.
|
||||
doc/next/7-stdlib/99-minor/bar/123.md: File must contain a complete sentence or a TODO.
|
||||
See doc/README.md for more information.
|
||||
doc/next/*stdlib/*minor/foo/123.md: File does not exist. Every API change must have a corresponding release note file.
|
||||
doc/next/7-stdlib/99-minor/foo/123.md: File does not exist. Every API change must have a corresponding release note file.
|
||||
See doc/README.md for more information.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
Check the error when the *stdlib/*minor directory is missing.
|
||||
|
||||
-- api.txt --
|
||||
pkg foo, type T #123
|
||||
pkg bar, type T #123
|
||||
-- want --
|
||||
No directory matches *stdlib/*minor.
|
||||
This shouldn't happen; please file a bug at https://go.dev/issues/new.
|
|
@ -1,9 +1,9 @@
|
|||
-- api.txt --
|
||||
pkg foo, type T #123
|
||||
pkg bar, type T #123
|
||||
-- foo/123.md --
|
||||
-- stdlib/minor/foo/123.md --
|
||||
TODO
|
||||
-- bar/123.md --
|
||||
-- stdlib/minor/bar/123.md --
|
||||
A sentence.
|
||||
-- want --
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче