MCPcopy
hub / github.com/go-git/go-git / newSubmoduleForRelativeURL

Function newSubmoduleForRelativeURL

submodule_test.go:302–327  ·  view source on GitHub ↗

newSubmoduleForRelativeURL constructs an in-memory Repository with the given parent remote URL configured as origin, plus a Submodule whose configured URL is the given submoduleURL. Returns the submodule for direct Repository() invocation. Pass parentRemoteURL = "" to omit the origin remote entirely

(c *C, parentRemoteURL, submoduleName, submoduleURL string)

Source from the content-addressed store, hash-verified

300// submodule for direct Repository() invocation. Pass parentRemoteURL
301// = "" to omit the origin remote entirely.
302func newSubmoduleForRelativeURL(c *C, parentRemoteURL, submoduleName, submoduleURL string) *Submodule {
303 repo := &Repository{
304 Storer: memory.NewStorage(),
305 wt: memfs.New(),
306 }
307 if parentRemoteURL != "" {
308 _, err := repo.CreateRemote(&config.RemoteConfig{
309 Name: DefaultRemoteName,
310 URLs: []string{parentRemoteURL},
311 })
312 c.Assert(err, IsNil)
313 }
314 worktree := &Worktree{
315 Filesystem: memfs.New(),
316 r: repo,
317 }
318 return &Submodule{
319 initialized: true,
320 c: &config.Submodule{
321 Name: submoduleName,
322 Path: submoduleName,
323 URL: submoduleURL,
324 },
325 w: worktree,
326 }
327}
328
329func (s *SubmoduleSuite) TestRepositoryRelativeURLHTTPSParent(c *C) {
330 sm := newSubmoduleForRelativeURL(c,

Calls 2

CreateRemoteMethod · 0.95
NewStorageFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…