You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the docs for create_submodule, it sounds like it proceeds through Submodule.add. According to the docs for Submodule.add, it sounds like add should still work fine if the submodule already exists. However that does not appear to be the case. Have included an example of the issue experienced below along with details about how to create an environment where this issue can be reproduced.
Example:
In [1]: importosIn [2]: importgitIn [3]: r=git.Repo.clone_from("https://github.com/conda-forge/feedstocks", "feedstocks")
In [4]: r.create_submodule(name="addict", path=os.path.join("feedstocks", "addict"), url="https://github.com/conda-forge/addict-feedstock", branch="master")
Out[4]: ---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
/zopt/conda2/envs/test/lib/python3.6/site-packages/IPython/core/formatters.pyin__call__(self, obj)
700type_pprinters=self.type_printers,
701deferred_pprinters=self.deferred_printers)
-->702printer.pretty(obj)
703printer.flush()
704returnstream.getvalue()
/zopt/conda2/envs/test/lib/python3.6/site-packages/IPython/lib/pretty.pyinpretty(self, obj)
393ifcallable(meth):
394returnmeth(obj, self, cycle)
-->395return_default_pprint(obj, self, cycle)
396finally:
397self.end_group()
/zopt/conda2/envs/test/lib/python3.6/site-packages/IPython/lib/pretty.pyin_default_pprint(obj, p, cycle)
508if_safe_getattr(klass, '__repr__', None) isnotobject.__repr__:
509# A user-provided repr. Find newlines and replace them with p.break_()-->510_repr_pprint(obj, p, cycle)
511return512p.begin_group(1, '<')
/zopt/conda2/envs/test/lib/python3.6/site-packages/IPython/lib/pretty.pyin_repr_pprint(obj, p, cycle)
699"""A pprint that just redirects to the normal repr function."""700# Find newlines and replace them with p.break_()-->701output=repr(obj)
702foridx,output_lineinenumerate(output.splitlines()):
703ifidx:
/zopt/conda2/envs/test/lib/python3.6/site-packages/git/objects/submodule/base.pyin__repr__(self)
170def__repr__(self):
171return"git.%s(name=%s, path=%s, url=%s, branch_path=%s)"\
-->172% (type(self).__name__, self._name, self.path, self.url, self.branch_path)
173174 @classmethod/zopt/conda2/envs/test/lib/python3.6/site-packages/gitdb/util.pyin__getattr__(self, attr)
254tobecreatedandset. Nexttimethesameattributeisreqeusted, itissimply255returnedfromourdict/slots. """
--> 256 self._set_cache_(attr)
257 # will raise in case the cache was not created
258 return object.__getattribute__(self, attr)
/zopt/conda2/envs/test/lib/python3.6/site-packages/git/objects/submodule/base.py in _set_cache_(self, attr)
133 self._branch_path = reader.get_value(self.k_head_option, git.Head.to_full_path(self.k_head_default))
134 elif attr == '_name':
--> 135 raise AttributeError("Cannot retrieve the name of a submodule if it was not set initially")
136 else:
137 super(Submodule, self)._set_cache_(attr)
AttributeError: Cannot retrieve the name of a submodule if it was not set initially
Just as clarification, this is basically showing that __repr__ fails. Though there were several other things that failed due to _name not being defined on the submodule (e.g. update). Am unclear on why _name is undefined for this case or why it matters so much. In any event, it seems to be ok to just use the user provide name as _name.
Based on the docs for
create_submodule
, it sounds like it proceeds throughSubmodule.add
. According to the docs forSubmodule.add
, it sounds likeadd
should still work fine if the submodule already exists. However that does not appear to be the case. Have included an example of the issue experienced below along with details about how to create an environment where this issue can be reproduced.Example:
Environment (with
conda
):FWIW relevant entry in
.gitmodules
:The text was updated successfully, but these errors were encountered: