Debian Codegraph @

submodule_windows_test.go

raw
1 package git
2
3 import (
4 "strings"
5
6 . "gopkg.in/check.v1"
7 )
8
9 // TestSubmoduleWindowsAbsoluteURLNotJoined verifies that absolute
10 // Windows paths in a submodule URL are recognised as absolute and
11 // therefore skip the relative-URL resolution branch. `path.IsAbs`
12 // alone returns false for `C:\…` and `\\server\share\…`; the
13 // production code pairs it with `filepath.IsAbs` so those cases
14 // don't get wrongly joined onto the superproject's remote URL.
15 func (s *SubmoduleSuite) TestSubmoduleWindowsAbsoluteURLNotJoined(c *C) {
16 for _, url := range []string{
17 `C:\path\to\submodule`,
18 `\\server\share\submodule`,
19 } {
20 c.Logf("url: %s", url)
21
22 sm := newSubmoduleForRelativeURL(c,
23 "file:///parent/origin", "child", url)
24
25 r, err := sm.Repository()
26 c.Assert(err, IsNil)
27
28 remotes, err := r.Remotes()
29 c.Assert(err, IsNil)
30 c.Assert(remotes, HasLen, 1)
31
32 got := remotes[0].Config().URLs[0]
33 c.Assert(strings.Contains(got, "/parent/origin"), Equals, false,
34 Commentf("absolute Windows submodule URL was wrongly joined onto the parent's remote: %q", got))
35 }
36 }