Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix 'Tree' object has no attribute '_name' when submodule path is normal path#1645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 1 commit intogitpython-developers:mainfromCosmosAtlas:main
Sep 6, 2023

Conversation

CosmosAtlas
Copy link
Contributor

@CosmosAtlasCosmosAtlas commentedSep 5, 2023
edited
Loading

When a repository have a.gitmodules file and the actual path defined in the git repository is not related to submodule, GitPython still assumes its a submodule.

To replicate:

# In a temp directorymkdirtestcdtestgit initmkdir DbConnectortouch DbConnector/readme.mdtouch .gitmodules# Put the context of the next segment in .gitmodulesgit add.git commit -m"test"
[submodule "DbConnector"]path = DbConnectorurl = https://github.com/chaconinc/DbConnector

Then in a python section

fromgit.repoimportRepor=Repo('.')r.submodules

the following error occurs

In [3]: r.submodules---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)Cell In[3], line 1----> 1 r.submodulesFile ~/.local/share/virtualenvs/GitPython-yvdsleke/lib/python3.11/site-packages/git/repo/base.py:423, in Repo.submodules(self)    418 @property    419 def submodules(self) -> "IterableList[Submodule]":    420     """    421     :return: git.IterableList(Submodule, ...) of direct submodules    422         available from the current head"""--> 423     return Submodule.list_items(self)File ~/.local/share/virtualenvs/GitPython-yvdsleke/lib/python3.11/site-packages/git/util.py:1184, in IterableObj.list_items(cls, repo, *args, **kwargs)   1175 """   1176 Find all items of this type - subclasses can specify args and kwargs differently.   1177 If no args are given, subclasses are obliged to return all items if no additional   (...)   1181   1182 :return: list(Item,...) list of item instances"""   1183 out_list: IterableList = IterableList(cls._id_attribute_)-> 1184 out_list.extend(cls.iter_items(repo, *args, **kwargs))   1185 return out_listFile ~/.local/share/virtualenvs/GitPython-yvdsleke/lib/python3.11/site-packages/git/objects/submodule/base.py:1406, in Submodule.iter_items(cls, repo, parent_commit, *Args, **kwargs)   1401         continue   1402     # END handle keyerror   1403 # END handle critical error   1404   1405 # fill in remaining info - saves time as it doesn't have to be parsed again-> 1406 sm._name = n   1407 if pc != repo.commit():   1408     sm._parent_commit = pcAttributeError: 'Tree' object has no attribute '_name'

Fixed by adding an additional check when determining whether the object is a submodule. Doing so makes sure onlySubmodule but notBlob orTree instances of theIndexObjUnion is considered a submodule.

PS: An example real project with this issuehttps://github.com/ChaoticOnyx/OnyxForum

@Byron
Copy link
Member

Thanks a lot for the fix!

Did you validate this with your particular repository? I am asking as there is no test for this. Thank you.

@CosmosAtlas
Copy link
ContributorAuthor

Did you validate this with your particular repository? I am asking as there is no test for this. Thank you.

Yes, I did. With the PR, nowr.submodules evaluates to[] as expected in both the test repository and the real-world example.

@Byron
Copy link
Member

Alright, I take your word for it.

If you have time, I'd appreciate a testcase in a follow-up PR, but have full understanding if that seems a bit hard to do with this test-setup.

Thanks for contributing.

@ByronByron merged commit830025b intogitpython-developers:mainSep 6, 2023
@ByronByron added this to thev3.1.35 - Bugfixes milestoneSep 6, 2023
Byron added a commit that referenced this pull requestSep 7, 2023
renovatebot referenced this pull request in allenporter/flux-localSep 8, 2023
[![MendRenovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)This PR contains the following updates:| Package | Change | Age | Adoption | Passing | Confidence ||---|---|---|---|---|---|| [GitPython](https://togithub.com/gitpython-developers/GitPython) |`==3.1.34` -> `==3.1.35` |[![age](https://developer.mend.io/api/mc/badges/age/pypi/GitPython/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/GitPython/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/GitPython/3.1.34/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/GitPython/3.1.34/3.1.35?slim=true)](https://docs.renovatebot.com/merge-confidence/)|---### Release Notes<details><summary>gitpython-developers/GitPython (GitPython)</summary>###[`v3.1.35`](https://togithub.com/gitpython-developers/GitPython/releases/tag/3.1.35):- a fix forCVE-2023-41040[CompareSource](https://togithub.com/gitpython-developers/GitPython/compare/3.1.34...3.1.35)#### What's Changed- Bump actions/checkout from 3 to 4 by[@&#8203;dependabot](https://togithub.com/dependabot) in[https://github.com/gitpython-developers/GitPython/pull/1643](https://togithub.com/gitpython-developers/GitPython/pull/1643)- Fix 'Tree' object has no attribute '\_name' when submodule path isnormal path by [@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas)in[https://github.com/gitpython-developers/GitPython/pull/1645](https://togithub.com/gitpython-developers/GitPython/pull/1645)- FixCVE-2023-41040 by[@&#8203;facutuesca](https://togithub.com/facutuesca) in[https://github.com/gitpython-developers/GitPython/pull/1644](https://togithub.com/gitpython-developers/GitPython/pull/1644)- Only make config more permissive in tests that need it by[@&#8203;EliahKagan](https://togithub.com/EliahKagan) in[https://github.com/gitpython-developers/GitPython/pull/1648](https://togithub.com/gitpython-developers/GitPython/pull/1648)- Added test for PR[#&#8203;1645](https://togithub.com/gitpython-developers/GitPython/issues/1645)submodule path by[@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas) in[https://github.com/gitpython-developers/GitPython/pull/1647](https://togithub.com/gitpython-developers/GitPython/pull/1647)- Fix Windows environment variable upcasing bug by[@&#8203;EliahKagan](https://togithub.com/EliahKagan) in[https://github.com/gitpython-developers/GitPython/pull/1650](https://togithub.com/gitpython-developers/GitPython/pull/1650)#### New Contributors- [@&#8203;CosmosAtlas](https://togithub.com/CosmosAtlas) made theirfirst contribution in[https://github.com/gitpython-developers/GitPython/pull/1645](https://togithub.com/gitpython-developers/GitPython/pull/1645)- [@&#8203;facutuesca](https://togithub.com/facutuesca) made their firstcontribution in[https://github.com/gitpython-developers/GitPython/pull/1644](https://togithub.com/gitpython-developers/GitPython/pull/1644)**Full Changelog**:gitpython-developers/GitPython@3.1.34...3.1.35</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined),Automerge - At any time (no schedule defined).🚦 **Automerge**: Enabled.♻ **Rebasing**: Whenever PR becomes conflicted, or you tick therebase/retry checkbox.🔕 **Ignore**: Close this PR and you won't be reminded about this updateagain.---- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, checkthis box---This PR has been generated by [MendRenovate](https://www.mend.io/free-developer-tools/renovate/). Viewrepository job log[here](https://developer.mend.io/github/allenporter/flux-local).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
otc-zuulbot pushed a commit to opentelekomcloud-infra/eyes_on_docs that referenced this pull requestSep 11, 2023
Bump gitpython from 3.1.32 to 3.1.35Bumps gitpython from 3.1.32 to 3.1.35.Release notesSourced from gitpython's releases.3.1.35 - a fix forCVE-2023-41040What's ChangedBump actions/checkout from 3 to 4 by @​dependabot ingitpython-developers/GitPython#1643Fix 'Tree' object has no attribute '_name' when submodule path is normal path by @​CosmosAtlas ingitpython-developers/GitPython#1645FixCVE-2023-41040 by @​facutuesca ingitpython-developers/GitPython#1644Only make config more permissive in tests that need it by @​EliahKagan ingitpython-developers/GitPython#1648Added test for PR #1645 submodule path by @​CosmosAtlas ingitpython-developers/GitPython#1647Fix Windows environment variable upcasing bug by @​EliahKagan ingitpython-developers/GitPython#1650New Contributors@​CosmosAtlas made their first contribution ingitpython-developers/GitPython#1645@​facutuesca made their first contribution ingitpython-developers/GitPython#1644Full Changelog: gitpython-developers/GitPython@3.1.34...3.1.353.1.34 - fix resource leakingWhat's Changedutil: close lockfile after opening successfully by @​skshetry ingitpython-developers/GitPython#1639New Contributors@​skshetry made their first contribution ingitpython-developers/GitPython#1639Full Changelog: gitpython-developers/GitPython@3.1.33...3.1.34v3.1.33 - with security fixWhat's ChangedWIP Quick doc by @​LeoDaCoda ingitpython-developers/GitPython#1608Partial clean up wrt mypy and black by @​bodograumann ingitpython-developers/GitPython#1617Disable merge_includes in config writers by @​bodograumann ingitpython-developers/GitPython#1618feat: full typing for "progress" parameter in Repo class by @​madebylydia ingitpython-developers/GitPython#1634FixCVE-2023-40590 by @​EliahKagan ingitpython-developers/GitPython#1636#1566 Creating a lock now uses python built-in "open()" method to work arou… by @​HageMaster3108 ingitpython-developers/GitPython#1619New Contributors@​LeoDaCoda made their first contribution ingitpython-developers/GitPython#1608@​bodograumann made their first contribution ingitpython-developers/GitPython#1617@​EliahKagan made their first contribution ingitpython-developers/GitPython#1636@​HageMaster3108 made their first contribution ingitpython-developers/GitPython#1619Full Changelog: gitpython-developers/GitPython@3.1.32...3.1.33Commitsc8e303f prepare next release09e1b3d Merge pull request #1650 from EliahKagan/envcase8017421 Merge pull request #1647 from CosmosAtlas/masterfafb4f6 updated docs to better describe testing procedure with new repo9da24d4 add test for submodule path not owned by submodule caseeebdb25 Eliminate duplication of git.util.cwd logicc7fad20 Fix Windows env var upcasing regression7296e5c Make test helper script a file, for readabilityd88372a Add test for Windows env var upcasing regression11839ab Merge pull request #1648 from EliahKagan/file-protocolAdditional commits viewable in compare viewDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting@dependabot rebase.Dependabot commands and optionsYou can trigger Dependabot actions by commenting on this PR:@dependabot rebase will rebase this PR@dependabot recreate will recreate this PR, overwriting any edits that have been made to it@dependabot merge will merge this PR after your CI passes on it@dependabot squash and merge will squash and merge this PR after your CI passes on it@dependabot cancel merge will cancel a previously requested merge and block automerging@dependabot reopen will reopen this PR if it is closed@dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)You can disable automated security fix PRs for this repo from the Security Alerts page.Reviewed-by: Vladimir Vshivkov
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
@CosmosAtlas@Byron

[8]ページ先頭

©2009-2025 Movatter.jp