aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/gitignore/dir_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:33:16 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:33:16 +0200
commitc69d5331743e49d3672897cf1c552e5e123d4509 (patch)
treedf503db7e8889cef313641b31808fc7404b400e3 /plumbing/format/gitignore/dir_test.go
parent67d34902b0c41ee5d6d283f4c5b6c2ad7db123fd (diff)
downloadgo-git-c69d5331743e49d3672897cf1c552e5e123d4509.tar.gz
plumbing: format, use os.UserHomeDir()
Diffstat (limited to 'plumbing/format/gitignore/dir_test.go')
-rw-r--r--plumbing/format/gitignore/dir_test.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/plumbing/format/gitignore/dir_test.go b/plumbing/format/gitignore/dir_test.go
index a3e7ba6..94ed7be 100644
--- a/plumbing/format/gitignore/dir_test.go
+++ b/plumbing/format/gitignore/dir_test.go
@@ -2,7 +2,6 @@ package gitignore
import (
"os"
- "os/user"
"strconv"
"github.com/go-git/go-billy/v5"
@@ -55,23 +54,23 @@ func (s *MatcherSuite) SetUpTest(c *C) {
s.GFS = fs
// setup root that contains user home
- usr, err := user.Current()
+ home, err := os.UserHomeDir()
c.Assert(err, IsNil)
fs = memfs.New()
- err = fs.MkdirAll(usr.HomeDir, os.ModePerm)
+ err = fs.MkdirAll(home, os.ModePerm)
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, gitconfigFile))
+ f, err = fs.Create(fs.Join(home, gitconfigFile))
c.Assert(err, IsNil)
_, err = f.Write([]byte("[core]\n"))
c.Assert(err, IsNil)
- _, err = f.Write([]byte(" excludesfile = " + strconv.Quote(fs.Join(usr.HomeDir, ".gitignore_global")) + "\n"))
+ _, err = f.Write([]byte(" excludesfile = " + strconv.Quote(fs.Join(home, ".gitignore_global")) + "\n"))
c.Assert(err, IsNil)
err = f.Close()
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, ".gitignore_global"))
+ f, err = fs.Create(fs.Join(home, ".gitignore_global"))
c.Assert(err, IsNil)
_, err = f.Write([]byte("# IntelliJ\n"))
c.Assert(err, IsNil)
@@ -86,10 +85,10 @@ func (s *MatcherSuite) SetUpTest(c *C) {
// root that contains user home, but missing ~/.gitconfig
fs = memfs.New()
- err = fs.MkdirAll(usr.HomeDir, os.ModePerm)
+ err = fs.MkdirAll(home, os.ModePerm)
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, ".gitignore_global"))
+ f, err = fs.Create(fs.Join(home, ".gitignore_global"))
c.Assert(err, IsNil)
_, err = f.Write([]byte("# IntelliJ\n"))
c.Assert(err, IsNil)
@@ -104,17 +103,17 @@ func (s *MatcherSuite) SetUpTest(c *C) {
// setup root that contains user home, but missing excludesfile entry
fs = memfs.New()
- err = fs.MkdirAll(usr.HomeDir, os.ModePerm)
+ err = fs.MkdirAll(home, os.ModePerm)
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, gitconfigFile))
+ f, err = fs.Create(fs.Join(home, gitconfigFile))
c.Assert(err, IsNil)
_, err = f.Write([]byte("[core]\n"))
c.Assert(err, IsNil)
err = f.Close()
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, ".gitignore_global"))
+ f, err = fs.Create(fs.Join(home, ".gitignore_global"))
c.Assert(err, IsNil)
_, err = f.Write([]byte("# IntelliJ\n"))
c.Assert(err, IsNil)
@@ -129,14 +128,14 @@ func (s *MatcherSuite) SetUpTest(c *C) {
// setup root that contains user home, but missing .gitnignore
fs = memfs.New()
- err = fs.MkdirAll(usr.HomeDir, os.ModePerm)
+ err = fs.MkdirAll(home, os.ModePerm)
c.Assert(err, IsNil)
- f, err = fs.Create(fs.Join(usr.HomeDir, gitconfigFile))
+ f, err = fs.Create(fs.Join(home, gitconfigFile))
c.Assert(err, IsNil)
_, err = f.Write([]byte("[core]\n"))
c.Assert(err, IsNil)
- _, err = f.Write([]byte(" excludesfile = " + strconv.Quote(fs.Join(usr.HomeDir, ".gitignore_global")) + "\n"))
+ _, err = f.Write([]byte(" excludesfile = " + strconv.Quote(fs.Join(home, ".gitignore_global")) + "\n"))
c.Assert(err, IsNil)
err = f.Close()
c.Assert(err, IsNil)