Merger: ensure_cloned() now looks for '.git'
merger.Repo() would not clone a directory if the target path already
exists, even though it might not have been cloned. Adjust the test to
look whether '.git' exist (which can be either a directory or a file in
the case of submodules).
I came accross this issue when using Zuul cloner to clone two
repositories, one having the other as a submodule.
Given two repositories:
- mediawiki/extension
- mediawiki (having 'mediawiki/extension' has a submodule to /extension)
We run: `zuul-cloner mediawiki mediawiki/extension`
It first clone the mediawiki repository with a placeholder directory for
the submodule. The directory structure is:
.
├── .git/
└── mediawiki/
└── extension/
When cloning mediawiki/extension, ensure_cloned() would skip it since
the directory exists. Looking for subpath '.git', we trick it in
cloning the repository resulting in:
.
├── .git/
│ └── modules/
│ └── extension/
└── mediawiki/
└── extension/
└── .git # note: a file, not a directory
My use case is cloning a mediawiki/core branch which has several
extensions registered as submodules that I am not going to initialize.
Change-Id: I4fe67a1db31adc2e23e8baf57528fce76f282986
2 files changed