Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11fff73

Browse files
authored
Merge pull request ishepard#122 from ishepard/fix-projectname-multiple-repos
Fix commit.project_name when multiple repos are given as parameters
2 parents 9e85db4 + 95c7ea8 commit 11fff73

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

pydriller/repository_mining.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,14 @@ def traverse_commits(self) -> Generator[Commit, None, None]:
164164
path_repo = self._clone_remote_repos(self._clone_folder(), path_repo)
165165

166166
git_repo = GitRepository(path_repo, self._conf)
167+
# saving the GitRepository object for further use
167168
self._conf.set_value("git_repo", git_repo)
169+
170+
# when multiple repos are given in input, this variable will serve as a reminder
171+
# of which one we are currently analyzing
172+
self._conf.set_value('path_to_repo', path_repo)
173+
174+
# checking that the filters are set correctly
168175
self._conf.sanity_check_filters()
169176

170177
logger.info('Analyzing git repository in %s', git_repo.path)

pydriller/utils/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def _sanity_check_repos(path_to_repo):
5959
@param path_to_repo: path to the repo as provided by the user.
6060
@return:
6161
"""
62-
if not isinstance(path_to_repo, str) and \
63-
not isinstance(path_to_repo, list):
62+
if not isinstance(path_to_repo, str) and not isinstance(path_to_repo, list):
6463
raise Exception("The path to the repo has to be of type 'string' or 'list of strings'!")
6564

6665
def _check_only_one_from_commit(self):

tests/test_commit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
from pydriller.git_repository import GitRepository
1615
from pathlib import Path
1716
import pytest

tests/test_repository_mining.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,22 @@ def test_clone_repo_to_not_existing():
234234
with pytest.raises(Exception):
235235
list(RepositoryMining("https://github.com/ishepard/pydriller",
236236
clone_repo_to="NOTEXISTINGDIR").traverse_commits())
237+
238+
239+
def test_projectname_multiple_repos():
240+
repos = [
241+
'test-repos/files_in_directories',
242+
'test-repos/files_in_directories',
243+
'test-repos/files_in_directories'
244+
]
245+
for commit in RepositoryMining(path_to_repo=repos).traverse_commits():
246+
assert commit.project_name == 'files_in_directories'
247+
248+
249+
def test_projectname_multiple_repos_remote():
250+
repos = [
251+
'https://github.com/ishepard/pydriller',
252+
'test-repos/pydriller'
253+
]
254+
for commit in RepositoryMining(path_to_repo=repos).traverse_commits():
255+
assert commit.project_name == 'pydriller'

0 commit comments

Comments
 (0)