greenmining 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
greenmining/__init__.py CHANGED
@@ -8,7 +8,7 @@ from greenmining.gsf_patterns import (
8
8
  is_green_aware,
9
9
  )
10
10
 
11
- __version__ = "1.2.0"
11
+ __version__ = "1.2.2"
12
12
 
13
13
 
14
14
  def fetch_repositories(
@@ -72,6 +72,7 @@ def analyze_repositories(
72
72
  github_token: str = None,
73
73
  since_date: str = None,
74
74
  to_date: str = None,
75
+ cleanup_after: bool = True,
75
76
  ):
76
77
  # Analyze multiple repositories from URLs.
77
78
  # Args:
@@ -107,6 +108,7 @@ def analyze_repositories(
107
108
  include_source_code=include_source_code,
108
109
  ssh_key_path=ssh_key_path,
109
110
  github_token=github_token,
111
+ cleanup_after=cleanup_after,
110
112
  **kwargs,
111
113
  )
112
114
 
@@ -460,12 +460,18 @@ class LocalRepoAnalyzer:
460
460
  if self.to_date:
461
461
  repo_config["to"] = self.to_date
462
462
 
463
- # Clone to specific path if needed
464
- local_path = self.clone_path / repo_name
463
+ # Use owner_repo format for unique directory names (avoids collisions
464
+ # when multiple repos share the same name, e.g. open-android/Android
465
+ # vs hmkcode/Android vs duckduckgo/Android).
466
+ safe_name = re.sub(r"[^a-z0-9_-]", "_", f"{owner}_{repo_name}".lower())
467
+ clone_parent = self.clone_path / safe_name
468
+ clone_parent.mkdir(parents=True, exist_ok=True)
469
+ local_path = clone_parent / repo_name
470
+
465
471
  if local_path.exists():
466
472
  shutil.rmtree(local_path)
467
473
 
468
- repo_config["clone_repo_to"] = str(self.clone_path)
474
+ repo_config["clone_repo_to"] = str(clone_parent)
469
475
 
470
476
  colored_print(f" Cloning to: {local_path}", "cyan")
471
477
 
@@ -540,10 +546,11 @@ class LocalRepoAnalyzer:
540
546
  return result
541
547
 
542
548
  finally:
543
- # Cleanup if requested
544
- if self.cleanup_after and local_path.exists():
545
- colored_print(f" Cleaning up: {local_path}", "cyan")
546
- shutil.rmtree(local_path, ignore_errors=True)
549
+ # Cleanup if requested (remove the unique parent dir to avoid
550
+ # accumulating empty owner_repo directories)
551
+ if self.cleanup_after and clone_parent.exists():
552
+ colored_print(f" Cleaning up: {clone_parent}", "cyan")
553
+ shutil.rmtree(clone_parent, ignore_errors=True)
547
554
 
548
555
  def _compute_process_metrics(self, repo_path: str) -> Dict[str, Any]:
549
556
  # Compute PyDriller process metrics for the repository.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: greenmining
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: An empirical Python library for Mining Software Repositories (MSR) in Green IT research
5
5
  Author-email: Adam Bouafia <a.bouafia@student.vu.nl>
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- greenmining/__init__.py,sha256=tBQKfeYTlXA0xKHlGeO51cT90Z643pzf_i1F7UscSnE,4096
1
+ greenmining/__init__.py,sha256=JNM9cXkhDfNhKNZ_PHurF4GJFOI1GRp2gbeYSgqTo6c,4165
2
2
  greenmining/__main__.py,sha256=NYOVS7D4w2XDLn6SyXHXPKE5GrNGOeoWSTb_KazgK5c,590
3
3
  greenmining/gsf_patterns.py,sha256=UvNJPY3HlAx1SicwUqci40TlLg8lCL0tszSOH4haxQs,55921
4
4
  greenmining/utils.py,sha256=-dnLUw9taCzvQ2dk6uc66GAohOFiXJFKs9TLSEPk5kM,2893
@@ -25,10 +25,10 @@ greenmining/services/commit_extractor.py,sha256=qBM9QpGzPZRmGMFufJ6gP8eWIuufTowL
25
25
  greenmining/services/data_aggregator.py,sha256=BU_HUb-8c0n0sa_7VZRB8jIVnaVhRLf-E6KA4ASh-08,19427
26
26
  greenmining/services/data_analyzer.py,sha256=0XqW-slrnt7RotrHDweOqKtoN8XIA7y6p7s2Jau6cMg,7431
27
27
  greenmining/services/github_graphql_fetcher.py,sha256=ZklXdEAc60KeFL83zRYMwW_-2OwMKpfPY7Wrifl0D50,11539
28
- greenmining/services/local_repo_analyzer.py,sha256=xs0q_iygUbJPMDKRpn2eaR66jjfmwnHA3YDDDB2lfAY,24857
28
+ greenmining/services/local_repo_analyzer.py,sha256=kdqN9O7GlmOs1_H1iNni1HEcCzF9bBCPeP3wMStGe5Q,25306
29
29
  greenmining/services/reports.py,sha256=nhJuYiA5tPD_9AjtgSLEnrpW3x15sZXrwIxpxQEBbh0,23219
30
- greenmining-1.2.0.dist-info/licenses/LICENSE,sha256=M7ma3JHGeiIZIs3ea0HTcFl_wLFPX2NZElUliYs4bCA,1083
31
- greenmining-1.2.0.dist-info/METADATA,sha256=YETcNjzPfjKujFZ16_u_bqBi5ZMc0LrOP2v2r6ThFA0,10522
32
- greenmining-1.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
33
- greenmining-1.2.0.dist-info/top_level.txt,sha256=nreXgXxZIWI-42yQknQ0HXtUrFnzZ8N1ra4Mdy2KcsI,12
34
- greenmining-1.2.0.dist-info/RECORD,,
30
+ greenmining-1.2.2.dist-info/licenses/LICENSE,sha256=M7ma3JHGeiIZIs3ea0HTcFl_wLFPX2NZElUliYs4bCA,1083
31
+ greenmining-1.2.2.dist-info/METADATA,sha256=41fXzXqw8FfchvNQ5faXpr9eDSw61fQQsIIkIOPcJvc,10522
32
+ greenmining-1.2.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
33
+ greenmining-1.2.2.dist-info/top_level.txt,sha256=nreXgXxZIWI-42yQknQ0HXtUrFnzZ8N1ra4Mdy2KcsI,12
34
+ greenmining-1.2.2.dist-info/RECORD,,