Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x/tools/go/vcs: fix FromDir returning bad root on Windows
Import path is a '/'-separated path. FromDir documentation says on return, root is the import path corresponding to the root of the repository. On Windows and other OSes where os.PathSeparator is not '/', that wasn't true since root would contain characters other than '/', and therefore it wasn't a valid import path corresponding to the root of the repository. Fix that by using filepath.ToSlash. Add test coverage for root value returned from FromDir, it was previously not tested. Additionally, remove a dubious statement from the documentation "(thus root is a prefix of importPath)". There is no variable importPath that is being referred to. It's also redundant and confusing. Without it, the description of root value matches the documentation of RepoRoot.Root struct field: // Root is the import path corresponding to the root of the // repository. Root string Fixes golang/go#7723. Change-Id: If9f5f55b5751e01a7f88b79d9b039402af3e9312 Reviewed-on: https://go-review.googlesource.com/18461 Reviewed-by: Chris Manghane <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]>
- Loading branch information