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

Method TestUpdateWithInitAndUpdate

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

Source from the content-addressed store, hash-verified

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