aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-07-11 08:53:03 +0100
committerGitHub <noreply@github.com>2023-07-11 08:53:03 +0100
commit56c4bf4ca9789505db7a6eefb910a7259c1fcb79 (patch)
tree3049fbf24af25a3e52bf7a391e959e837e032e3a /repository_test.go
parentdc17aae6503560777a665c9cfb0d2fcb3a9a9274 (diff)
parent5dad9b23030e344a4fd1458df0c50e6ada55a01a (diff)
downloadgo-git-56c4bf4ca9789505db7a6eefb910a7259c1fcb79.tar.gz
Merge pull request #809 from AriehSchneier/tilde-user-path
*: Handle paths starting with ~Username
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go17
1 files changed, 13 insertions, 4 deletions
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) {