MCPcopy Create free account
hub / github.com/go-git/go-git / TestUpdateWithInitAndUpdate

Method TestUpdateWithInitAndUpdate

submodule_test.go:143–180  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

141}
142
143func (s *SubmoduleSuite) TestUpdateWithInitAndUpdate(c *C) {
144 if testing.Short() {
145 c.Skip("skipping test in short mode.")
146 }
147
148 sm, err := s.Worktree.Submodule("basic")
149 c.Assert(err, IsNil)
150
151 err = sm.Update(&SubmoduleUpdateOptions{
152 Init: true,
153 })
154 c.Assert(err, IsNil)
155
156 idx, err := s.Repository.Storer.Index()
157 c.Assert(err, IsNil)
158
159 for i, e := range idx.Entries {
160 if e.Name == "basic" {
161 e.Hash = plumbing.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d")
162 }
163
164 idx.Entries[i] = e
165 }
166
167 err = s.Repository.Storer.SetIndex(idx)
168 c.Assert(err, IsNil)
169
170 err = sm.Update(&SubmoduleUpdateOptions{})
171 c.Assert(err, IsNil)
172
173 r, err := sm.Repository()
174 c.Assert(err, IsNil)
175
176 ref, err := r.Reference(plumbing.HEAD, true)
177 c.Assert(err, IsNil)
178 c.Assert(ref.Hash().String(), Equals, "b029517f6300c2da0f4b651b8642506cd6aaf45d")
179
180}
181
182func (s *SubmoduleSuite) TestSubmodulesInit(c *C) {
183 sm, err := s.Worktree.Submodules()

Callers

nothing calls this directly

Calls 11

NewHashFunction · 0.92
ShortMethod · 0.80
SubmoduleMethod · 0.80
RepositoryMethod · 0.80
SkipMethod · 0.65
IndexMethod · 0.65
SetIndexMethod · 0.65
ReferenceMethod · 0.65
StringMethod · 0.65
HashMethod · 0.65
UpdateMethod · 0.45

Tested by

no test coverage detected