git-recap 0.1.0__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.
git_recap/__init__.py ADDED
File without changes
git_recap/fetcher.py ADDED
@@ -0,0 +1,86 @@
1
+ import argparse
2
+ from datetime import datetime, timedelta
3
+ from git_recap.providers.github_fetcher import GitHubFetcher
4
+ from git_recap.providers.azure_fetcher import AzureFetcher
5
+ from git_recap.providers.gitlab_fetcher import GitLabFetcher
6
+
7
+ def main():
8
+ parser = argparse.ArgumentParser(
9
+ description="Fetch user authored messages from repositories."
10
+ )
11
+ parser.add_argument(
12
+ '--provider',
13
+ required=True,
14
+ choices=['github', 'azure', 'gitlab'],
15
+ help='Platform name (github, azure, or gitlab)'
16
+ )
17
+ parser.add_argument('--pat', required=True, help='Personal Access Token')
18
+ parser.add_argument(
19
+ '--organization-url',
20
+ help='Organization URL for Azure DevOps'
21
+ )
22
+ parser.add_argument(
23
+ '--gitlab-url',
24
+ help='GitLab URL (default: https://gitlab.com)'
25
+ )
26
+ parser.add_argument(
27
+ '--start-date',
28
+ type=lambda s: datetime.fromisoformat(s),
29
+ default=(datetime.now() - timedelta(days=7)),
30
+ help='Start date in ISO format (default: 7 days before now)'
31
+ )
32
+ parser.add_argument(
33
+ '--end-date',
34
+ type=lambda s: datetime.fromisoformat(s),
35
+ default=datetime.now(),
36
+ help='End date in ISO format (default: now)'
37
+ )
38
+ parser.add_argument(
39
+ '--limit',
40
+ type=int,
41
+ default=10,
42
+ help='Number of bullet points to return'
43
+ )
44
+ parser.add_argument(
45
+ '--repos',
46
+ nargs='*',
47
+ help='Repository names to filter (leave empty for all)'
48
+ )
49
+
50
+ args = parser.parse_args()
51
+
52
+ fetcher = None
53
+ if args.provider == 'github':
54
+ fetcher = GitHubFetcher(
55
+ pat=args.pat,
56
+ start_date=args.start_date,
57
+ end_date=args.end_date,
58
+ repo_filter=args.repos
59
+ )
60
+ elif args.provider == 'azure':
61
+ if not args.organization_url:
62
+ print("Organization URL is required for Azure DevOps")
63
+ exit(1)
64
+ fetcher = AzureFetcher(
65
+ pat=args.pat,
66
+ organization_url=args.organization_url,
67
+ start_date=args.start_date,
68
+ end_date=args.end_date,
69
+ repo_filter=args.repos
70
+ )
71
+ elif args.provider == 'gitlab':
72
+ gitlab_url = args.gitlab_url if args.gitlab_url else 'https://gitlab.com'
73
+ fetcher = GitLabFetcher(
74
+ pat=args.pat,
75
+ url=gitlab_url,
76
+ start_date=args.start_date,
77
+ end_date=args.end_date,
78
+ repo_filter=args.repos
79
+ )
80
+
81
+ messages = fetcher.get_authored_messages(limit=args.limit)
82
+ for msg in messages:
83
+ print(f"- {msg}")
84
+
85
+ if __name__ == '__main__':
86
+ main()
@@ -0,0 +1,9 @@
1
+ from git_recap.providers.azure_fetcher import AzureFetcher
2
+ from git_recap.providers.github_fetcher import GitHubFetcher
3
+ from git_recap.providers.gitlab_fetcher import GitLabFetcher
4
+
5
+ __all__ = [
6
+ "AzureFetcher",
7
+ "GitHubFetcher",
8
+ "GitLabFetcher"
9
+ ]
@@ -0,0 +1,156 @@
1
+ from azure.devops.connection import Connection
2
+ from msrest.authentication import BasicAuthentication
3
+ from datetime import datetime
4
+ from typing import List, Dict, Any
5
+ from git_recap.providers.base_fetcher import BaseFetcher
6
+
7
+ class AzureFetcher(BaseFetcher):
8
+ def __init__(self, pat: str, organization_url: str, start_date=None, end_date=None, repo_filter=None, authors=None):
9
+ # authors should be passed as a list of unique names (e.g., email or unique id)
10
+ super().__init__(pat, start_date, end_date, repo_filter, authors)
11
+ self.organization_url = organization_url
12
+ credentials = BasicAuthentication('', self.pat)
13
+ self.connection = Connection(base_url=self.organization_url, creds=credentials)
14
+ self.core_client = self.connection.clients.get_core_client()
15
+ self.git_client = self.connection.clients.get_git_client()
16
+ # If no authors provided, default to an empty list.
17
+ if authors is None:
18
+ self.authors = []
19
+
20
+ def _filter_by_date(self, date_obj: datetime) -> bool:
21
+ if self.start_date and date_obj < self.start_date:
22
+ return False
23
+ if self.end_date and date_obj > self.end_date:
24
+ return False
25
+ return True
26
+
27
+ def _stop_fetching(self, date_obj: datetime) -> bool:
28
+ if self.start_date and date_obj < self.start_date:
29
+ return True
30
+ return False
31
+
32
+ def fetch_commits(self) -> List[Dict[str, Any]]:
33
+ entries = []
34
+ processed_commits = set()
35
+ projects = self.core_client.get_projects().value
36
+ for project in projects:
37
+ repos = self.git_client.get_repositories(project.id)
38
+ for repo in repos:
39
+ if self.repo_filter and repo.name not in self.repo_filter:
40
+ continue
41
+ # Iterate over provided authors
42
+ for author in self.authors:
43
+ try:
44
+ commits = self.git_client.get_commits(
45
+ project=project.id,
46
+ repository_id=repo.id,
47
+ search_criteria={"author": author}
48
+ )
49
+ except Exception:
50
+ continue
51
+ for commit in commits:
52
+ # Azure DevOps returns a commit with an 'author' property
53
+ commit_date = commit.author.date # type: datetime
54
+ if self._filter_by_date(commit_date):
55
+ sha = commit.commit_id
56
+ if sha not in processed_commits:
57
+ entry = {
58
+ "type": "commit",
59
+ "repo": repo.name,
60
+ "message": commit.comment.strip(),
61
+ "timestamp": commit_date,
62
+ "sha": sha,
63
+ }
64
+ entries.append(entry)
65
+ processed_commits.add(sha)
66
+ if self._stop_fetching(commit_date):
67
+ break
68
+ return entries
69
+
70
+ def fetch_pull_requests(self) -> List[Dict[str, Any]]:
71
+ entries = []
72
+ processed_pr_commits = set()
73
+ projects = self.core_client.get_projects().value
74
+ for project in projects:
75
+ repos = self.git_client.get_repositories(project.id)
76
+ for repo in repos:
77
+ if self.repo_filter and repo.name not in self.repo_filter:
78
+ continue
79
+ try:
80
+ pull_requests = self.git_client.get_pull_requests(
81
+ repository_id=repo.id,
82
+ search_criteria={}
83
+ )
84
+ except Exception:
85
+ continue
86
+ for pr in pull_requests:
87
+ # Check that the PR creator is one of our authors.
88
+ if pr.created_by.unique_name not in self.authors:
89
+ continue
90
+ pr_date = pr.creation_date # type: datetime
91
+ if not self._filter_by_date(pr_date):
92
+ continue
93
+
94
+ pr_entry = {
95
+ "type": "pull_request",
96
+ "repo": repo.name,
97
+ "message": pr.title,
98
+ "timestamp": pr_date,
99
+ "pr_number": pr.pull_request_id,
100
+ }
101
+ entries.append(pr_entry)
102
+
103
+ try:
104
+ pr_commits = self.git_client.get_pull_request_commits(
105
+ project=project.id,
106
+ repository_id=repo.id,
107
+ pull_request_id=pr.pull_request_id
108
+ )
109
+ except Exception:
110
+ pr_commits = []
111
+ for pr_commit in pr_commits:
112
+ commit_date = pr_commit.author.date
113
+ if self._filter_by_date(commit_date):
114
+ sha = pr_commit.commit_id
115
+ if sha in processed_pr_commits:
116
+ continue
117
+ pr_commit_entry = {
118
+ "type": "commit_from_pr",
119
+ "repo": repo.name,
120
+ "message": pr_commit.comment.strip(),
121
+ "timestamp": commit_date,
122
+ "sha": sha,
123
+ "pr_title": pr.title,
124
+ }
125
+ entries.append(pr_commit_entry)
126
+ processed_pr_commits.add(sha)
127
+ if self._stop_fetching(pr_date):
128
+ break
129
+ return entries
130
+
131
+ def fetch_issues(self) -> List[Dict[str, Any]]:
132
+ entries = []
133
+ # Azure DevOps issues are typically tracked as Work Items.
134
+ wit_client = self.connection.clients.get_work_item_tracking_client()
135
+ # Query work items for each author; this is a simplified WIQL query.
136
+ for author in self.authors:
137
+ wiql = f"SELECT [System.Id], [System.Title], [System.CreatedDate] FROM WorkItems WHERE [System.AssignedTo] CONTAINS '{author}'"
138
+ try:
139
+ query_result = wit_client.query_by_wiql(wiql).work_items
140
+ except Exception:
141
+ continue
142
+ for item_ref in query_result:
143
+ work_item = wit_client.get_work_item(item_ref.id)
144
+ # The created date is a string; convert it to a datetime.
145
+ created_date = datetime.fromisoformat(work_item.fields["System.CreatedDate"])
146
+ if self._filter_by_date(created_date):
147
+ entry = {
148
+ "type": "issue",
149
+ "repo": "N/A",
150
+ "message": work_item.fields["System.Title"],
151
+ "timestamp": created_date,
152
+ }
153
+ entries.append(entry)
154
+ if self._stop_fetching(created_date):
155
+ break
156
+ return entries
@@ -0,0 +1,79 @@
1
+ from abc import ABC, abstractmethod
2
+ from datetime import datetime, timezone
3
+ from typing import List, Optional, Dict, Any
4
+
5
+ class BaseFetcher(ABC):
6
+ def __init__(
7
+ self,
8
+ pat: str,
9
+ start_date: Optional[datetime] = None,
10
+ end_date: Optional[datetime] = None,
11
+ repo_filter: Optional[List[str]] = None,
12
+ authors: Optional[List[str]]=None
13
+ ):
14
+ self.pat = pat
15
+ if start_date is not None:
16
+ self.start_date = start_date if start_date.tzinfo is not None else start_date.replace(tzinfo=timezone.utc)
17
+ else:
18
+ self.start_date = None
19
+
20
+ if end_date is not None:
21
+ self.end_date = end_date if end_date.tzinfo is not None else end_date.replace(tzinfo=timezone.utc)
22
+ else:
23
+ self.end_date = None
24
+
25
+ self.repo_filter = repo_filter or []
26
+ self.limit = -1
27
+ self.authors = [] if authors is None else authors
28
+
29
+ @abstractmethod
30
+ def fetch_commits(self) -> List[str]:
31
+ pass
32
+
33
+ @abstractmethod
34
+ def fetch_pull_requests(self) -> List[str]:
35
+ pass
36
+
37
+ @abstractmethod
38
+ def fetch_issues(self) -> List[str]:
39
+ pass
40
+
41
+ def get_authored_messages(self) -> List[Dict[str, Any]]:
42
+ """
43
+ Aggregates all commit, pull request, and issue entries into a single list,
44
+ ensuring no duplicate commits (based on SHA) are present, and then sorts
45
+ them in chronological order based on their timestamp.
46
+ """
47
+ commit_entries = self.fetch_commits()
48
+ pr_entries = self.fetch_pull_requests()
49
+ issue_entries = self.fetch_issues()
50
+
51
+ all_entries = pr_entries + commit_entries + issue_entries
52
+
53
+ # For commit-related entries, remove duplicates (if any) based on SHA.
54
+ unique_entries = {}
55
+ for entry in all_entries:
56
+ if entry.get("type") in ["commit", "commit_from_pr"]:
57
+ sha = entry.get("sha")
58
+ if sha in unique_entries:
59
+ continue
60
+ unique_entries[sha] = entry
61
+ else:
62
+ # For pull requests and issues, we can create a unique key.
63
+ key = f"{entry['type']}_{entry['repo']}_{entry['timestamp']}"
64
+ unique_entries[key] = entry
65
+
66
+ final_entries = list(unique_entries.values())
67
+ # Sort all entries by their timestamp.
68
+ final_entries.sort(key=lambda x: x["timestamp"])
69
+ return self.convert_timestamps_to_str(final_entries)
70
+
71
+ @staticmethod
72
+ def convert_timestamps_to_str(entries: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
73
+ """
74
+ Converts the timestamp field from datetime to string format for each entry in the list.
75
+ """
76
+ for entry in entries:
77
+ if isinstance(entry.get("timestamp"), datetime):
78
+ entry["timestamp"] = entry["timestamp"].isoformat()
79
+ return entries
@@ -0,0 +1,115 @@
1
+ from github import Github
2
+ from datetime import datetime
3
+ from typing import List, Dict, Any
4
+ from git_recap.providers.base_fetcher import BaseFetcher
5
+
6
+ class GitHubFetcher(BaseFetcher):
7
+ def __init__(self, pat: str, start_date=None, end_date=None, repo_filter=None, authors=None):
8
+ super().__init__(pat, start_date, end_date, repo_filter, authors)
9
+ self.github = Github(self.pat)
10
+ self.user = self.github.get_user()
11
+ self.authors.append(self.user.login)
12
+
13
+ def _stop_fetching(self, date_obj: datetime) -> bool:
14
+ if self.start_date and date_obj < self.start_date:
15
+ return True
16
+ return False
17
+
18
+ def _filter_by_date(self, date_obj: datetime) -> bool:
19
+ if self.start_date and date_obj < self.start_date:
20
+ return False
21
+ if self.end_date and date_obj > self.end_date:
22
+ return False
23
+ return True
24
+
25
+ def fetch_commits(self) -> List[Dict[str, Any]]:
26
+ entries = []
27
+ processed_commits = set()
28
+ repos = self.user.get_repos()
29
+ for repo in repos:
30
+ if self.repo_filter and repo.name not in self.repo_filter:
31
+ continue
32
+ for author in self.authors:
33
+ commits = repo.get_commits(author=author)
34
+ for i, commit in enumerate(commits, start=1):
35
+ commit_date = commit.commit.author.date
36
+ if self._filter_by_date(commit_date):
37
+ sha = commit.sha
38
+ if sha not in processed_commits:
39
+ entry = {
40
+ "type": "commit",
41
+ "repo": repo.name,
42
+ "message": commit.commit.message.strip(),
43
+ "timestamp": commit_date,
44
+ "sha": sha,
45
+ }
46
+ entries.append(entry)
47
+ processed_commits.add(sha)
48
+ if self._stop_fetching(commit_date):
49
+ break
50
+ return entries
51
+
52
+ def fetch_pull_requests(self) -> List[Dict[str, Any]]:
53
+ entries = []
54
+ # Maintain a local set to skip duplicate commits already captured in a PR.
55
+ processed_pr_commits = set()
56
+ repos = self.user.get_repos()
57
+ for repo in repos:
58
+ if self.repo_filter and repo.name not in self.repo_filter:
59
+ continue
60
+ pulls = repo.get_pulls(state='all')
61
+ for i, pr in enumerate(pulls, start=1):
62
+ if pr.user.login not in self.authors:
63
+ continue
64
+ pr_date = pr.updated_at # alternatively, use pr.created_at
65
+ if not self._filter_by_date(pr_date):
66
+ continue
67
+
68
+ # Add the pull request itself.
69
+ pr_entry = {
70
+ "type": "pull_request",
71
+ "repo": repo.name,
72
+ "message": pr.title,
73
+ "timestamp": pr_date,
74
+ "pr_number": pr.number,
75
+ }
76
+ entries.append(pr_entry)
77
+
78
+ # Now, add commits associated with this pull request.
79
+ pr_commits = pr.get_commits()
80
+ for pr_commit in pr_commits:
81
+ commit_date = pr_commit.commit.author.date
82
+ if self._filter_by_date(commit_date):
83
+ sha = pr_commit.sha
84
+ if sha in processed_pr_commits:
85
+ continue
86
+ pr_commit_entry = {
87
+ "type": "commit_from_pr",
88
+ "repo": repo.name,
89
+ "message": pr_commit.commit.message.strip(),
90
+ "timestamp": commit_date,
91
+ "sha": sha,
92
+ "pr_title": pr.title,
93
+ }
94
+ entries.append(pr_commit_entry)
95
+ processed_pr_commits.add(sha)
96
+ if self._stop_fetching(pr_date):
97
+ break
98
+ return entries
99
+
100
+ def fetch_issues(self) -> List[Dict[str, Any]]:
101
+ entries = []
102
+ issues = self.user.get_issues()
103
+ for i, issue in enumerate(issues, start=1):
104
+ issue_date = issue.created_at
105
+ if self._filter_by_date(issue_date):
106
+ entry = {
107
+ "type": "issue",
108
+ "repo": issue.repository.name,
109
+ "message": issue.title,
110
+ "timestamp": issue_date,
111
+ }
112
+ entries.append(entry)
113
+ if self._stop_fetching(issue_date):
114
+ break
115
+ return entries
@@ -0,0 +1,125 @@
1
+ import gitlab
2
+ from datetime import datetime
3
+ from typing import List, Dict, Any
4
+ from git_recap.providers.base_fetcher import BaseFetcher
5
+
6
+ class GitLabFetcher(BaseFetcher):
7
+ def __init__(self, pat: str, url: str = 'https://gitlab.com', start_date=None, end_date=None, repo_filter=None, authors=None):
8
+ super().__init__(pat, start_date, end_date, repo_filter, authors)
9
+ self.gl = gitlab.Gitlab(url, private_token=self.pat)
10
+ self.gl.auth()
11
+ # Default to the authenticated user's username if no authors are provided.
12
+ if authors is None:
13
+ self.authors = [self.gl.user.username]
14
+ else:
15
+ self.authors = authors
16
+
17
+ def _filter_by_date(self, date_str: str) -> bool:
18
+ date_obj = datetime.fromisoformat(date_str)
19
+ if self.start_date and date_obj < self.start_date:
20
+ return False
21
+ if self.end_date and date_obj > self.end_date:
22
+ return False
23
+ return True
24
+
25
+ def _stop_fetching(self, date_str: str) -> bool:
26
+ date_obj = datetime.fromisoformat(date_str)
27
+ if self.start_date and date_obj < self.start_date:
28
+ return True
29
+ return False
30
+
31
+ def fetch_commits(self) -> List[Dict[str, Any]]:
32
+ entries = []
33
+ processed_commits = set()
34
+ projects = self.gl.projects.list(owned=True, all=True)
35
+ for project in projects:
36
+ if self.repo_filter and project.name not in self.repo_filter:
37
+ continue
38
+ for author in self.authors:
39
+ try:
40
+ commits = project.commits.list(author=author)
41
+ except Exception:
42
+ continue
43
+ for commit in commits:
44
+ commit_date = commit.committed_date
45
+ if self._filter_by_date(commit_date):
46
+ sha = commit.id
47
+ if sha not in processed_commits:
48
+ entry = {
49
+ "type": "commit",
50
+ "repo": project.name,
51
+ "message": commit.message.strip(),
52
+ "timestamp": commit_date,
53
+ "sha": sha,
54
+ }
55
+ entries.append(entry)
56
+ processed_commits.add(sha)
57
+ return entries
58
+
59
+ def fetch_pull_requests(self) -> List[Dict[str, Any]]:
60
+ entries = []
61
+ processed_pr_commits = set()
62
+ projects = self.gl.projects.list(owned=True, all=True)
63
+ for project in projects:
64
+ if self.repo_filter and project.name not in self.repo_filter:
65
+ continue
66
+ # Fetch merge requests (the GitLab equivalent of pull requests)
67
+ merge_requests = project.mergerequests.list(state='all', all=True)
68
+ for mr in merge_requests:
69
+ if mr.author['username'] not in self.authors:
70
+ continue
71
+ mr_date = mr.created_at
72
+ if not self._filter_by_date(mr_date):
73
+ continue
74
+ mr_entry = {
75
+ "type": "pull_request",
76
+ "repo": project.name,
77
+ "message": mr.title,
78
+ "timestamp": mr_date,
79
+ "pr_number": mr.iid,
80
+ }
81
+ entries.append(mr_entry)
82
+ try:
83
+ mr_commits = mr.commits()
84
+ except Exception:
85
+ mr_commits = []
86
+ for mr_commit in mr_commits:
87
+ commit_date = mr_commit['created_at']
88
+ if self._filter_by_date(commit_date):
89
+ sha = mr_commit['id']
90
+ if sha in processed_pr_commits:
91
+ continue
92
+ mr_commit_entry = {
93
+ "type": "commit_from_pr",
94
+ "repo": project.name,
95
+ "message": mr_commit['message'].strip(),
96
+ "timestamp": commit_date,
97
+ "sha": sha,
98
+ "pr_title": mr.title,
99
+ }
100
+ entries.append(mr_commit_entry)
101
+ processed_pr_commits.add(sha)
102
+ if self._stop_fetching(mr_date):
103
+ break
104
+ return entries
105
+
106
+ def fetch_issues(self) -> List[Dict[str, Any]]:
107
+ entries = []
108
+ projects = self.gl.projects.list(owned=True, all=True)
109
+ for project in projects:
110
+ if self.repo_filter and project.name not in self.repo_filter:
111
+ continue
112
+ issues = project.issues.list(assignee_id=self.gl.user.id)
113
+ for issue in issues:
114
+ issue_date = issue.created_at
115
+ if self._filter_by_date(issue_date):
116
+ entry = {
117
+ "type": "issue",
118
+ "repo": project.name,
119
+ "message": issue.title,
120
+ "timestamp": issue_date,
121
+ }
122
+ entries.append(entry)
123
+ if self._stop_fetching(issue_date):
124
+ break
125
+ return entries
git_recap/utils.py ADDED
@@ -0,0 +1,93 @@
1
+ from datetime import datetime
2
+ from typing import List, Dict, Any
3
+ from collections import defaultdict
4
+
5
+ def parse_entries_to_txt(entries: List[Dict[str, Any]]) -> str:
6
+ """
7
+ Groups entries by day (YYYY-MM-DD) and produces a plain text summary.
8
+
9
+ Each day's header is the date string, followed by bullet points that list:
10
+ - type (commit, commit_from_pr, pull_request, issue)
11
+ - repo name
12
+ - message text
13
+ - for pull requests: PR number or for commits from PR: pr_title
14
+ """
15
+ # Group entries by date (YYYY-MM-DD)
16
+ grouped = defaultdict(list)
17
+ for entry in entries:
18
+ ts = entry.get("timestamp")
19
+ # Convert timestamp to a datetime object if necessary
20
+ if isinstance(ts, str):
21
+ dt = datetime.fromisoformat(ts)
22
+ else:
23
+ dt = ts
24
+ day = dt.strftime("%Y-%m-%d")
25
+ grouped[day].append(entry)
26
+
27
+ # Sort the days chronologically
28
+ sorted_days = sorted(grouped.keys())
29
+
30
+ # Build the output text
31
+ lines = []
32
+ for day in sorted_days:
33
+ lines.append(day + ":")
34
+ # Optionally, sort the entries for that day if needed (e.g., by timestamp)
35
+ day_entries = sorted(grouped[day], key=lambda x: x["timestamp"])
36
+ for entry in day_entries:
37
+ typ = entry.get("type", "N/A")
38
+ repo = entry.get("repo", "N/A")
39
+ message = entry.get("message", "").strip()
40
+ # Build extra details for pull requests and commits from pull requests
41
+ extra = ""
42
+ if typ == "pull_request":
43
+ pr_number = entry.get("pr_number")
44
+ if pr_number is not None:
45
+ extra = f" (PR #{pr_number})"
46
+ elif typ == "commit_from_pr":
47
+ pr_title = entry.get("pr_title", "")
48
+ if pr_title:
49
+ extra = f" (PR: {pr_title})"
50
+ # Format the bullet point
51
+ bullet = f" - [{typ.replace('_', ' ').title()}] in {repo}: {message}{extra}"
52
+ lines.append(bullet)
53
+ lines.append("") # blank line between days
54
+
55
+ return "\n".join(lines)
56
+
57
+ # Example usage:
58
+ if __name__ == "__main__":
59
+ # Assuming `output` is the list of dict entries from your fetcher.
60
+ output = [
61
+ {
62
+ "type": "commit_from_pr",
63
+ "repo": "AiCore",
64
+ "message": "feat: update TODOs for ObservabilityDashboard with new input/output tokens and cross workspace analysis",
65
+ "timestamp": "2025-03-14T00:17:02+00:00",
66
+ "sha": "d1f185f09e4fcb775374b9468755b8463c94a605",
67
+ "pr_title": "Unified ai integration error monitoring"
68
+ },
69
+ {
70
+ "type": "commit_from_pr",
71
+ "repo": "AiCore",
72
+ "message": "feat: enhance token usage visualization in ObservabilityDashboard with grouped bar chart",
73
+ "timestamp": "2025-03-15T00:20:15+00:00",
74
+ "sha": "875457b9c80076d821f36cc646ec354ef5124088",
75
+ "pr_title": "Unified ai integration error monitoring"
76
+ },
77
+ {
78
+ "type": "pull_request",
79
+ "repo": "AiCore",
80
+ "message": "Unified ai integration error monitoring",
81
+ "timestamp": "2025-03-15T21:47:13+00:00",
82
+ "pr_number": 5
83
+ },
84
+ {
85
+ "type": "commit",
86
+ "repo": "AiCore",
87
+ "message": "feat: update openai package version to 1.66.3 in requirements.txt and setup.py",
88
+ "timestamp": "2025-03-15T23:22:28+00:00",
89
+ "sha": "9f7e30ebcca8c909274dd8ca91fcfbd17bbf9195"
90
+ },
91
+ ]
92
+ context_txt = parse_entries_to_txt(output)
93
+ print(context_txt)
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-recap
3
+ Version: 0.1.0
4
+ Summary: A modular Python tool that aggregates and formats user-authored messages from repositories.
5
+ Author: Bruno V.
6
+ Author-email: bruno.vitorino@tecnico.ulisboa.pt
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: PyGithub==2.6.1
13
+ Requires-Dist: azure-devops==7.1.0b4
14
+ Requires-Dist: python-gitlab==5.6.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: license-file
21
+ Dynamic: requires-dist
22
+ Dynamic: summary
23
+
24
+ # Git Recap
25
+
26
+ Git Recap is a modular Python tool that aggregates and formats user-authored messages from repositories hosted on GitHub, Azure DevOps, and GitLab. It fetches commit messages, pull requests (along with their associated commits), and issues, then consolidates and sorts these events into a clear, chronological summary. This summary is output as a plain text string that can serve as context for large language models or other analysis tools.
27
+
28
+ ## Features
29
+
30
+ - **Multi-Platform Support:**
31
+ Retrieve messages from:
32
+ - GitHub (via [PyGitHub](https://pygithub.readthedocs.io/en/stable/))
33
+ - Azure DevOps (via [azure-devops Python API](https://github.com/microsoft/azure-devops-python-api))
34
+ - GitLab (via [python-gitlab](https://python-gitlab.readthedocs.io/))
35
+
36
+ - **Flexible Date Filtering:**
37
+ Specify start and end dates (automatically converted to UTC if no timezone info is provided) to restrict the range of events.
38
+
39
+ - **Author Filtering:**
40
+ Optionally specify one or more authors. By default, the authenticated user is used.
41
+
42
+ - **Output Schema:**
43
+ Each fetched event is stored in a standardized dictionary format with keys such as:
44
+ - `type` (commit, commit_from_pr, pull_request, issue)
45
+ - `repo`
46
+ - `message`
47
+ - `timestamp`
48
+ - Additional keys like `sha`, `pr_title`, and `pr_number` for context
49
+
50
+ - **Chronological Aggregation:**
51
+ All events are merged and sorted in chronological order.
52
+ A helper function then parses the JSON output into a plain text summary grouped by day, making it ideal as context for LLMs.
53
+
54
+ ## File Structure
55
+
56
+ ```
57
+ git_recap/
58
+ ├── README.md
59
+ ├── requirements.txt
60
+ └── src
61
+ ├── __init__.py
62
+ ├── fetcher.py
63
+ └── providers
64
+ ├── __init__.py
65
+ ├── base_fetcher.py
66
+ ├── github_fetcher.py
67
+ ├── azure_fetcher.py
68
+ └── gitlab_fetcher.py
69
+ ```
70
+
71
+ - **fetcher.py:**
72
+ Contains the main entry point which parses command-line arguments (provider, PAT, dates, repo filters, etc.) and invokes the appropriate provider fetcher.
73
+
74
+ - **providers/base_fetcher.py:**
75
+ Defines the abstract base class with common functionality such as date filtering and aggregating messages.
76
+
77
+ - **providers/github_fetcher.py:**
78
+ Implements GitHub-specific logic for fetching commits, pull requests (including their commits), and issues.
79
+
80
+ - **providers/azure_fetcher.py & providers/gitlab_fetcher.py:**
81
+ Implement similar logic for Azure DevOps and GitLab respectively.
82
+
83
+ ## Installation
84
+
85
+ 1. Clone the repository:
86
+
87
+ ```bash
88
+ git clone https://github.com/yourusername/git_recap.git
89
+ cd git_recap
90
+ ```
91
+
92
+ 2. Create a virtual environment (optional but recommended):
93
+
94
+ ```bash
95
+ python -m venv venv
96
+ source venv/bin/activate # On Windows use: venv\Scripts\activate
97
+ ```
98
+
99
+ 3. Install dependencies:
100
+
101
+ ```bash
102
+ pip install -r requirements.txt
103
+ ```
104
+
105
+ ## Usage
106
+
107
+ Run the main script with the required parameters. For example:
108
+
109
+ ### GitHub
110
+ ```bash
111
+ python src/fetcher.py --provider github --pat YOUR_GITHUB_PAT --start-date 2025-03-07T00:00:00 --end-date 2025-03-15T23:59:59 --repos Repo1 Repo2
112
+ ```
113
+
114
+ ### Azure DevOps
115
+ ```bash
116
+ python src/fetcher.py --provider azure --pat YOUR_AZURE_PAT --organization-url https://dev.azure.com/YOURORG --start-date 2025-03-07T00:00:00 --end-date 2025-03-15T23:59:59 --repos Repo1 Repo2
117
+ ```
118
+
119
+ ### GitLab
120
+ ```bash
121
+ python src/fetcher.py --provider gitlab --pat YOUR_GITLAB_PAT --gitlab-url https://gitlab.example.com --start-date 2025-03-07T00:00:00 --end-date 2025-03-15T23:59:59 --repos Repo1 Repo2
122
+ ```
123
+
124
+ ## Contributing
125
+
126
+ Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
127
+
128
+ ## License
129
+
130
+ This project is licensed under the terms of the [MIT License](LICENSE).
131
+
132
+ ## Acknowledgements
133
+
134
+ - [PyGitHub](https://pygithub.readthedocs.io/en/stable/)
135
+ - [Azure DevOps Python API](https://github.com/microsoft/azure-devops-python-api)
136
+ - [python-gitlab](https://python-gitlab.readthedocs.io/)
@@ -0,0 +1,13 @@
1
+ git_recap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ git_recap/fetcher.py,sha256=oRlenzd9OsiBkCtpUgSZGlUoUnVpdkolUZhFOF1USBs,2677
3
+ git_recap/utils.py,sha256=mAGZ6bNklBmE-qpA6RG17_Bka8WRXzjLRAAGS9p3QXk,3646
4
+ git_recap/providers/__init__.py,sha256=amk4xSzKOkjW8RaorBSJoiDnjiyFHoz8jFrgFM6Wx_o,256
5
+ git_recap/providers/azure_fetcher.py,sha256=KMqXdIKYGp_EC2BHKhqBIfdXJ7nENx6OSSdqtySa618,7270
6
+ git_recap/providers/base_fetcher.py,sha256=d8QuadaVaGxksbImrnAV10k21i21OSxVopOQYDbuIcA,2902
7
+ git_recap/providers/github_fetcher.py,sha256=yq5MF4VoZww5-yKxyKb270X1EZsRqtDc9P6XKBVs6s0,4770
8
+ git_recap/providers/gitlab_fetcher.py,sha256=2ivuBdVJVgT7qGqTakkMYkkOHd2veyh54in6ttr59FM,5284
9
+ git_recap-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
+ git_recap-0.1.0.dist-info/METADATA,sha256=a1A8NFSnAhjd6haIP5SpzzNbIdKjUSpS92OLJNrS6b8,4721
11
+ git_recap-0.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
12
+ git_recap-0.1.0.dist-info/top_level.txt,sha256=1JUKd3WPB8c3LcD1deIW-1UTmYzA0zJqwugAz72YZ_o,10
13
+ git_recap-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (78.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ git_recap