MCPcopy Create free account
hub / github.com/libgit2/pygit2 / update

Method update

pygit2/submodules.py:85–121  ·  view source on GitHub ↗

Update a submodule. This will clone a missing submodule and checkout the subrepository to the commit specified in the index of the containing repository. If the submodule repository doesn't contain the target commit (e.g. because fetchRecurseSubmodules isn't set), th

(
        self,
        init: bool = False,
        callbacks: Optional[RemoteCallbacks] = None,
        depth: int = 0,
    )

Source from the content-addressed store, hash-verified

83 check_error(err)
84
85 def update(
86 self,
87 init: bool = False,
88 callbacks: Optional[RemoteCallbacks] = None,
89 depth: int = 0,
90 ) -> None:
91 """
92 Update a submodule. This will clone a missing submodule and checkout
93 the subrepository to the commit specified in the index of the
94 containing repository. If the submodule repository doesn't contain the
95 target commit (e.g. because fetchRecurseSubmodules isn't set), then the
96 submodule is fetched using the fetch options supplied in options.
97
98 Parameters:
99
100 init
101 If the submodule is not initialized, setting this flag to True will
102 initialize the submodule before updating. Otherwise, this will raise
103 an error if attempting to update an uninitialized repository.
104
105 callbacks
106 Optional RemoteCallbacks to clone or fetch the submodule.
107
108 depth
109 Number of commits to fetch.
110 The default is 0 (full commit history).
111 """
112
113 opts = ffi.new('git_submodule_update_options *')
114 C.git_submodule_update_options_init(
115 opts, C.GIT_SUBMODULE_UPDATE_OPTIONS_VERSION
116 )
117 opts.fetch_opts.depth = depth
118
119 with git_fetch_options(callbacks, opts=opts.fetch_opts) as payload:
120 err = C.git_submodule_update(self._subm, int(init), opts)
121 payload.check_error(err)
122
123 def reload(self, force: bool = False) -> None:
124 """

Callers 10

gen_blob_sha1Function · 0.45
test_submodule_openFunction · 0.45
test_init_and_updateFunction · 0.45
test_specified_updateFunction · 0.45
test_update_instanceFunction · 0.45
test_oneshot_updateFunction · 0.45
test_submodule_statusFunction · 0.45
updateMethod · 0.45

Calls 2

git_fetch_optionsFunction · 0.85
check_errorMethod · 0.80

Tested by 8

test_submodule_openFunction · 0.36
test_init_and_updateFunction · 0.36
test_specified_updateFunction · 0.36
test_update_instanceFunction · 0.36
test_oneshot_updateFunction · 0.36
test_submodule_statusFunction · 0.36