From 5dad9b23030e344a4fd1458df0c50e6ada55a01a Mon Sep 17 00:00:00 2001 From: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:08:04 +1000 Subject: *: Handle paths starting with ~username Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> --- repository_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'repository_test.go') diff --git a/repository_test.go b/repository_test.go index 50384e7..9e000a3 100644 --- a/repository_test.go +++ b/repository_test.go @@ -8,6 +8,7 @@ import ( "io" "os" "os/exec" + "os/user" "path/filepath" "regexp" "strings" @@ -551,11 +552,19 @@ func (s *RepositorySuite) TestPlainOpenTildePath(c *C) { c.Assert(err, IsNil) c.Assert(r, NotNil) - path := strings.Replace(dir, strings.Split(dir, ".tmp")[0], "~/", 1) - - r, err = PlainOpen(path) + currentUser, err := user.Current() c.Assert(err, IsNil) - c.Assert(r, NotNil) + // remove domain for windows + username := currentUser.Username[strings.Index(currentUser.Username, "\\")+1:] + + homes := []string{"~/", "~" + username + "/"} + for _, home := range homes { + path := strings.Replace(dir, strings.Split(dir, ".tmp")[0], home, 1) + + r, err = PlainOpen(path) + c.Assert(err, IsNil) + c.Assert(r, NotNil) + } } func (s *RepositorySuite) TestPlainOpenBare(c *C) { -- cgit