]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/vcs: also check file mode when identifying VCS root
authorZeke Lu <lvzecai@gmail.com>
Wed, 2 Nov 2022 16:55:51 +0000 (16:55 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 3 Nov 2022 15:33:59 +0000 (15:33 +0000)
commitbb3965695d3bc3586fba55c7b8d5e8a56cd4c0c9
tree2a32c56f32b62c333122be794220622bf62b1a1e
parent3e3a8fe5bed87845e7c93da50378403564ad9e69
cmd/go/internal/vcs: also check file mode when identifying VCS root

Currently, FromDir identifies a VCS checkout directory just by checking
whether it contains a specified file. This is not enough. For example,
although there is a ".git" file (a plain file, not a directory) in a
git submodule directory, this directory is not a git repository root.

This change takes the file mode into account. As of now, the filename
and file mode for the supported VCS tools are:

- Mercurial:    .hg             directory
- Git:          .git            directory
- Bazaar:       .bzr            directory
- Subversion:   .svn            directory
- Fossil:       .fslckout       plain file
- Fossil:       _FOSSIL_        plain file

This CL effectively reverts CL 30948 for #10322.

Fixes #53640.

Change-Id: Iea316c7e983232903bddb7e7f6dbaa55e8498685
GitHub-Last-Rev: 7a2d6ff6f939c892f4740c57ea36c031bf7bd6be
GitHub-Pull-Request: golang/go#56296
Reviewed-on: https://go-review.googlesource.com/c/go/+/443597
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/vcs/vcs.go
src/cmd/go/internal/vcs/vcs_test.go
src/cmd/go/testdata/script/version_buildvcs_fossil.txt
src/cmd/go/testdata/script/version_buildvcs_git.txt