greenmining 0.1.6__tar.gz → 0.1.8__tar.gz

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.
Files changed (38) hide show
  1. {greenmining-0.1.6 → greenmining-0.1.8}/CHANGELOG.md +6 -0
  2. {greenmining-0.1.6/greenmining.egg-info → greenmining-0.1.8}/PKG-INFO +6 -6
  3. {greenmining-0.1.6 → greenmining-0.1.8}/README.md +4 -4
  4. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/__init__.py +1 -1
  5. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/__version__.py +1 -1
  6. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/commit_extractor.py +69 -13
  7. {greenmining-0.1.6 → greenmining-0.1.8/greenmining.egg-info}/PKG-INFO +6 -6
  8. {greenmining-0.1.6 → greenmining-0.1.8}/pyproject.toml +2 -2
  9. {greenmining-0.1.6 → greenmining-0.1.8}/LICENSE +0 -0
  10. {greenmining-0.1.6 → greenmining-0.1.8}/MANIFEST.in +0 -0
  11. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/__main__.py +0 -0
  12. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/cli.py +0 -0
  13. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/config.py +0 -0
  14. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/controllers/__init__.py +0 -0
  15. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/controllers/repository_controller.py +0 -0
  16. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/gsf_patterns.py +0 -0
  17. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/main.py +0 -0
  18. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/models/__init__.py +0 -0
  19. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/models/aggregated_stats.py +0 -0
  20. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/models/analysis_result.py +0 -0
  21. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/models/commit.py +0 -0
  22. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/models/repository.py +0 -0
  23. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/presenters/__init__.py +0 -0
  24. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/presenters/console_presenter.py +0 -0
  25. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/__init__.py +0 -0
  26. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/data_aggregator.py +0 -0
  27. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/data_analyzer.py +0 -0
  28. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/github_fetcher.py +0 -0
  29. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/services/reports.py +0 -0
  30. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining/utils.py +0 -0
  31. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining.egg-info/SOURCES.txt +0 -0
  32. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining.egg-info/dependency_links.txt +0 -0
  33. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining.egg-info/entry_points.txt +0 -0
  34. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining.egg-info/requires.txt +0 -0
  35. {greenmining-0.1.6 → greenmining-0.1.8}/greenmining.egg-info/top_level.txt +0 -0
  36. {greenmining-0.1.6 → greenmining-0.1.8}/pytest.ini +0 -0
  37. {greenmining-0.1.6 → greenmining-0.1.8}/setup.cfg +0 -0
  38. {greenmining-0.1.6 → greenmining-0.1.8}/setup.py +0 -0
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.7] - 2025-12-02
4
+
5
+ ### Added
6
+ - New release
7
+
8
+
3
9
  ## [0.1.6] - 2025-12-02
4
10
 
5
11
  ### Added
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: greenmining
3
- Version: 0.1.6
4
- Summary: Green Software Foundation (GSF) patterns mining tool for microservices repositories
3
+ Version: 0.1.8
4
+ Summary: Analyze GitHub repositories to identify green software engineering patterns and energy-efficient practices
5
5
  Author-email: Your Name <your.email@example.com>
6
6
  Maintainer-email: Your Name <your.email@example.com>
7
7
  License: MIT
@@ -63,11 +63,11 @@ Green mining for microservices repositories.
63
63
 
64
64
  ## Overview
65
65
 
66
- `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices. It detects 76 official Green Software Foundation patterns across cloud, web, AI, database, networking, and general categories.
66
+ `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices and energy-efficient patterns. It detects 76 sustainable software patterns across cloud, web, AI, database, networking, and general categories.
67
67
 
68
68
  ## Features
69
69
 
70
- - 🔍 **76 GSF Patterns**: Detect official Green Software Foundation patterns
70
+ - 🔍 **76 Sustainability Patterns**: Detect energy-efficient and environmentally conscious coding practices
71
71
  - 📊 **Repository Mining**: Analyze 100+ microservices repositories from GitHub
72
72
  - 📈 **Green Awareness Detection**: Identify sustainability-focused commits
73
73
  - 📄 **Comprehensive Reports**: Generate analysis reports in multiple formats
@@ -128,7 +128,7 @@ greenmining report
128
128
  from greenmining import GSF_PATTERNS, is_green_aware, get_pattern_by_keywords
129
129
 
130
130
  # Check available patterns
131
- print(f"Total GSF patterns: {len(GSF_PATTERNS)}") # 76
131
+ print(f"Total patterns: {len(GSF_PATTERNS)}") # 76
132
132
 
133
133
  # Detect green awareness in commit messages
134
134
  commit_msg = "Optimize Redis caching to reduce energy consumption"
@@ -168,7 +168,7 @@ for commit in commits:
168
168
  print(f" Patterns: {result['known_pattern']}")
169
169
  ```
170
170
 
171
- #### Access GSF Patterns Data
171
+ #### Access Sustainability Patterns Data
172
172
 
173
173
  ```python
174
174
  from greenmining import GSF_PATTERNS
@@ -8,11 +8,11 @@ Green mining for microservices repositories.
8
8
 
9
9
  ## Overview
10
10
 
11
- `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices. It detects 76 official Green Software Foundation patterns across cloud, web, AI, database, networking, and general categories.
11
+ `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices and energy-efficient patterns. It detects 76 sustainable software patterns across cloud, web, AI, database, networking, and general categories.
12
12
 
13
13
  ## Features
14
14
 
15
- - 🔍 **76 GSF Patterns**: Detect official Green Software Foundation patterns
15
+ - 🔍 **76 Sustainability Patterns**: Detect energy-efficient and environmentally conscious coding practices
16
16
  - 📊 **Repository Mining**: Analyze 100+ microservices repositories from GitHub
17
17
  - 📈 **Green Awareness Detection**: Identify sustainability-focused commits
18
18
  - 📄 **Comprehensive Reports**: Generate analysis reports in multiple formats
@@ -73,7 +73,7 @@ greenmining report
73
73
  from greenmining import GSF_PATTERNS, is_green_aware, get_pattern_by_keywords
74
74
 
75
75
  # Check available patterns
76
- print(f"Total GSF patterns: {len(GSF_PATTERNS)}") # 76
76
+ print(f"Total patterns: {len(GSF_PATTERNS)}") # 76
77
77
 
78
78
  # Detect green awareness in commit messages
79
79
  commit_msg = "Optimize Redis caching to reduce energy consumption"
@@ -113,7 +113,7 @@ for commit in commits:
113
113
  print(f" Patterns: {result['known_pattern']}")
114
114
  ```
115
115
 
116
- #### Access GSF Patterns Data
116
+ #### Access Sustainability Patterns Data
117
117
 
118
118
  ```python
119
119
  from greenmining import GSF_PATTERNS
@@ -8,7 +8,7 @@ from greenmining.gsf_patterns import (
8
8
  is_green_aware,
9
9
  )
10
10
 
11
- __version__ = "0.1.0"
11
+ __version__ = "0.1.8"
12
12
 
13
13
  __all__ = [
14
14
  "Config",
@@ -1,3 +1,3 @@
1
1
  """Version information for greenmining."""
2
2
 
3
- __version__ = "0.1.6"
3
+ __version__ = "0.1.7"
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
  from typing import Any, Optional
7
7
 
8
8
  import click
9
- from pydriller import Repository
9
+ from github import Github
10
10
  from tqdm import tqdm
11
11
 
12
12
  from greenmining.config import get_config
@@ -21,20 +21,28 @@ from greenmining.utils import (
21
21
 
22
22
 
23
23
  class CommitExtractor:
24
- """Extracts commit data from repositories."""
25
-
26
- def __init__(self, max_commits: int = 50, skip_merges: bool = True, days_back: int = 730):
24
+ """Extracts commit data from repositories using GitHub API."""
25
+
26
+ def __init__(
27
+ self,
28
+ max_commits: int = 50,
29
+ skip_merges: bool = True,
30
+ days_back: int = 730,
31
+ github_token: str | None = None,
32
+ ):
27
33
  """Initialize commit extractor.
28
34
 
29
35
  Args:
30
36
  max_commits: Maximum commits per repository
31
37
  skip_merges: Skip merge commits
32
38
  days_back: Only analyze commits from last N days
39
+ github_token: GitHub API token (optional)
33
40
  """
34
41
  self.max_commits = max_commits
35
42
  self.skip_merges = skip_merges
36
43
  self.days_back = days_back
37
44
  self.cutoff_date = datetime.now() - timedelta(days=days_back)
45
+ self.github = Github(github_token) if github_token else None
38
46
 
39
47
  def extract_from_repositories(self, repositories: list[dict[str, Any]]) -> list[dict[str, Any]]:
40
48
  """Extract commits from list of repositories.
@@ -77,7 +85,7 @@ class CommitExtractor:
77
85
 
78
86
  @retry_on_exception(max_retries=2, delay=5.0, exceptions=(Exception,))
79
87
  def _extract_repo_commits(self, repo: dict[str, Any]) -> list[dict[str, Any]]:
80
- """Extract commits from a single repository.
88
+ """Extract commits from a single repository using GitHub API.
81
89
 
82
90
  Args:
83
91
  repo: Repository metadata dictionary
@@ -86,27 +94,35 @@ class CommitExtractor:
86
94
  List of commit dictionaries
87
95
  """
88
96
  commits = []
89
- repo_url = repo["clone_url"]
90
97
  repo_name = repo["full_name"]
91
98
 
92
99
  try:
93
- # Use PyDriller to traverse commits
94
- commit_count = 0
100
+ # Get repository from GitHub API
101
+ if not self.github:
102
+ config = get_config()
103
+ self.github = Github(config.GITHUB_TOKEN)
95
104
 
96
- for commit in Repository(
97
- repo_url, only_no_merge=self.skip_merges, since=self.cutoff_date
98
- ).traverse_commits():
105
+ gh_repo = self.github.get_repo(repo_name)
106
+
107
+ # Get recent commits (GitHub API returns in reverse chronological order)
108
+ commit_count = 0
99
109
 
110
+ for commit in gh_repo.get_commits():
100
111
  # Skip if reached max commits
101
112
  if commit_count >= self.max_commits:
102
113
  break
103
114
 
115
+ # Skip merge commits if requested
116
+ if self.skip_merges and len(commit.parents) > 1:
117
+ continue
118
+
104
119
  # Skip trivial commits
105
- if not commit.msg or len(commit.msg.strip()) < 10:
120
+ commit_msg = commit.commit.message
121
+ if not commit_msg or len(commit_msg.strip()) < 10:
106
122
  continue
107
123
 
108
124
  # Extract commit data
109
- commit_data = self._extract_commit_metadata(commit, repo_name)
125
+ commit_data = self._extract_commit_metadata_from_github(commit, repo_name)
110
126
  commits.append(commit_data)
111
127
  commit_count += 1
112
128
 
@@ -158,6 +174,46 @@ class CommitExtractor:
158
174
  "in_main_branch": commit.in_main_branch if hasattr(commit, "in_main_branch") else True,
159
175
  }
160
176
 
177
+ def _extract_commit_metadata_from_github(self, commit, repo_name: str) -> dict[str, Any]:
178
+ """Extract metadata from GitHub API commit object.
179
+
180
+ Args:
181
+ commit: GitHub API commit object
182
+ repo_name: Repository name
183
+
184
+ Returns:
185
+ Dictionary with commit metadata
186
+ """
187
+ # Get modified files and stats
188
+ files_changed = []
189
+ lines_added = 0
190
+ lines_deleted = 0
191
+
192
+ try:
193
+ for file in commit.files:
194
+ files_changed.append(file.filename)
195
+ lines_added += file.additions
196
+ lines_deleted += file.deletions
197
+ except Exception:
198
+ pass
199
+
200
+ return {
201
+ "commit_id": commit.sha,
202
+ "repo_name": repo_name,
203
+ "date": commit.commit.committer.date.isoformat(),
204
+ "author": commit.commit.author.name,
205
+ "author_email": commit.commit.author.email,
206
+ "message": commit.commit.message.strip(),
207
+ "files_changed": files_changed[:20], # Limit to 20 files
208
+ "lines_added": lines_added,
209
+ "lines_deleted": lines_deleted,
210
+ "insertions": lines_added,
211
+ "deletions": lines_deleted,
212
+ "is_merge": len(commit.parents) > 1,
213
+ "branches": [],
214
+ "in_main_branch": True,
215
+ }
216
+
161
217
  def save_results(self, commits: list[dict[str, Any]], output_file: Path, repos_count: int):
162
218
  """Save extracted commits to JSON file.
163
219
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: greenmining
3
- Version: 0.1.6
4
- Summary: Green Software Foundation (GSF) patterns mining tool for microservices repositories
3
+ Version: 0.1.8
4
+ Summary: Analyze GitHub repositories to identify green software engineering patterns and energy-efficient practices
5
5
  Author-email: Your Name <your.email@example.com>
6
6
  Maintainer-email: Your Name <your.email@example.com>
7
7
  License: MIT
@@ -63,11 +63,11 @@ Green mining for microservices repositories.
63
63
 
64
64
  ## Overview
65
65
 
66
- `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices. It detects 76 official Green Software Foundation patterns across cloud, web, AI, database, networking, and general categories.
66
+ `greenmining` is a Python library and CLI tool for analyzing GitHub repositories to identify green software engineering practices and energy-efficient patterns. It detects 76 sustainable software patterns across cloud, web, AI, database, networking, and general categories.
67
67
 
68
68
  ## Features
69
69
 
70
- - 🔍 **76 GSF Patterns**: Detect official Green Software Foundation patterns
70
+ - 🔍 **76 Sustainability Patterns**: Detect energy-efficient and environmentally conscious coding practices
71
71
  - 📊 **Repository Mining**: Analyze 100+ microservices repositories from GitHub
72
72
  - 📈 **Green Awareness Detection**: Identify sustainability-focused commits
73
73
  - 📄 **Comprehensive Reports**: Generate analysis reports in multiple formats
@@ -128,7 +128,7 @@ greenmining report
128
128
  from greenmining import GSF_PATTERNS, is_green_aware, get_pattern_by_keywords
129
129
 
130
130
  # Check available patterns
131
- print(f"Total GSF patterns: {len(GSF_PATTERNS)}") # 76
131
+ print(f"Total patterns: {len(GSF_PATTERNS)}") # 76
132
132
 
133
133
  # Detect green awareness in commit messages
134
134
  commit_msg = "Optimize Redis caching to reduce energy consumption"
@@ -168,7 +168,7 @@ for commit in commits:
168
168
  print(f" Patterns: {result['known_pattern']}")
169
169
  ```
170
170
 
171
- #### Access GSF Patterns Data
171
+ #### Access Sustainability Patterns Data
172
172
 
173
173
  ```python
174
174
  from greenmining import GSF_PATTERNS
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "greenmining"
7
- version = "0.1.6"
8
- description = "Green Software Foundation (GSF) patterns mining tool for microservices repositories"
7
+ version = "0.1.8"
8
+ description = "Analyze GitHub repositories to identify green software engineering patterns and energy-efficient practices"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
11
11
  license = {text = "MIT"}
File without changes
File without changes
File without changes
File without changes
File without changes