forked from go-git/go-git
-
Notifications
You must be signed in to change notification settings - Fork 1
/
repository_windows_test.go
46 lines (35 loc) · 1 KB
/
repository_windows_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package git
import (
"fmt"
"strings"
"github.com/go-git/go-billy/v5/util"
"github.com/go-git/go-git/v5/storage/memory"
. "gopkg.in/check.v1"
)
// preReceiveHook returns the bytes of a pre-receive hook script
// that prints m before exiting successfully
func preReceiveHook(m string) []byte {
return []byte(fmt.Sprintf("#!C:/Program\\ Files/Git/usr/bin/sh.exe\nprintf '%s'\n", m))
}
func (s *RepositorySuite) TestCloneFileUrlWindows(c *C) {
dir := c.MkDir()
r, err := PlainInit(dir, false)
c.Assert(err, IsNil)
err = util.WriteFile(r.wt, "foo", nil, 0755)
c.Assert(err, IsNil)
w, err := r.Worktree()
c.Assert(err, IsNil)
_, err = w.Add("foo")
c.Assert(err, IsNil)
_, err = w.Commit("foo", &CommitOptions{
Author: defaultSignature(),
Committer: defaultSignature(),
})
c.Assert(err, IsNil)
url := "file:///" + strings.ReplaceAll(dir, "\\", "/")
c.Assert(url, Matches, "file:///[A-Za-z]:/.*")
_, err = Clone(memory.NewStorage(), nil, &CloneOptions{
URL: url,
})
c.Assert(err, IsNil)
}