Skip to content

Commit ddd5ec5

Browse files
committed
Fix create_submodule when submodule exists
Uses a workaround already accepted upstream to fix `create_submodule` when the submodule already exists. In particular naming the submodule with the user provided name. By being able to use `create_submodule`, this script runs substantially faster than when calling `submodule`. Reason being calling `submodule` lists all submodules in the repo and then selects the one we named. Whereas `create_submodule` simply provides us the requested submodule. So using this workaround is necessary for the performance improvement it provides. ref: gitpython-developers/GitPython#679
1 parent dbcad97 commit ddd5ec5

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

conda_forge_webservices/update_feedstocks.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ def update_feedstock(org_name, repo_name):
2424
)
2525

2626
# Get the submodule
27-
try:
28-
feedstock_submodule = feedstocks_repo.submodule(name)
29-
except ValueError:
30-
feedstock_submodule = feedstocks_repo.create_submodule(
31-
name=name,
32-
path=os.path.join("feedstocks", name),
33-
url=repo_gh.clone_url,
34-
branch="master"
35-
)
27+
feedstock_submodule = feedstocks_repo.create_submodule(
28+
name=name,
29+
path=os.path.join("feedstocks", name),
30+
url=repo_gh.clone_url,
31+
branch="master"
32+
)
33+
# Hack needed if the submodule already exists.
34+
# Borrows the fix accepted upstream.
35+
# PR: https://github.com/gitpython-developers/GitPython/pull/679
36+
feedstock_submodule._name = name
3637

3738
# Update the feedstocks submodule
3839
feedstock_submodule.update(init=True, recursive=False, force=True)

0 commit comments

Comments
 (0)