From 8956568036ef22a1bad9e349d9b3a991cd6a744f Mon Sep 17 00:00:00 2001 From: Edward Muller Date: Mon, 30 Nov 2015 16:04:18 -0800 Subject: [PATCH] EvalSymlinks in Contains() check git's root command (maybe others vcs as well) resolve symlinks, so try that too. PS: In git's case we can possible use rev-parse --show-cdup + extra logic to find the root of the repo instead. Need to figure out what other vcs root commands do as well. Fixes #339 --- Changelog.md | 6 +++++- vcs.go | 9 +++++++++ version.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 97013ff..2da3bff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,8 @@ -# v31 2015/12/2 +# v32 2015/12/02 + +* Eval Symlinks in Contains() check. + +# v31 2015/12/02 * In restore, mention which package had the problem -- @shurcool diff --git a/vcs.go b/vcs.go index bfbcd46..39159c4 100644 --- a/vcs.go +++ b/vcs.go @@ -128,6 +128,15 @@ func (vf vcsFiles) Contains(path string) bool { if strings.EqualFold(f, path) { return true } + // git's root command (maybe other vcs as well) resolve symlinks, so try that too + // FIXME: rev-parse --show-cdup + extra logic will fix this for git but also need to validate the other vcs commands. This is maybe temporary. + p, err := filepath.EvalSymlinks(path) + if err != nil { + return false + } + if strings.EqualFold(f, p) { + return true + } } // No matches by either method diff --git a/version.go b/version.go index 11576b3..f8d10ee 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -const version = 31 +const version = 32 var cmdVersion = &Command{ Usage: "version",