github-issue-exporter 0.0.1__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.
- github_issue_exporter/__init__.py +18 -0
- github_issue_exporter/__main__.py +6 -0
- github_issue_exporter/cli/__init__.py +0 -0
- github_issue_exporter/cli/main.py +311 -0
- github_issue_exporter/core/__init__.py +0 -0
- github_issue_exporter/core/auth.py +186 -0
- github_issue_exporter/core/config.py +237 -0
- github_issue_exporter/core/export_engine.py +344 -0
- github_issue_exporter/core/filesystem.py +241 -0
- github_issue_exporter/core/github_client.py +334 -0
- github_issue_exporter/core/transformer.py +148 -0
- github_issue_exporter-0.0.1.dist-info/METADATA +195 -0
- github_issue_exporter-0.0.1.dist-info/RECORD +15 -0
- github_issue_exporter-0.0.1.dist-info/WHEEL +4 -0
- github_issue_exporter-0.0.1.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
from typing import Dict, Any, List, Optional
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from github_issue_exporter import __version__
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DataTransformer:
|
|
7
|
+
"""Transform GitHub API data to desired JSON format."""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.tool_version = __version__
|
|
11
|
+
|
|
12
|
+
def _parse_datetime(self, datetime_str: Optional[str]) -> Optional[str]:
|
|
13
|
+
"""Parse and validate datetime string."""
|
|
14
|
+
if not datetime_str:
|
|
15
|
+
return None
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
# GitHub API returns ISO format strings
|
|
19
|
+
dt = datetime.fromisoformat(datetime_str.replace('Z', '+00:00'))
|
|
20
|
+
return dt.isoformat()
|
|
21
|
+
except Exception:
|
|
22
|
+
return datetime_str
|
|
23
|
+
|
|
24
|
+
def _extract_user_login(self, user_data: Optional[Dict[str, Any]]) -> Optional[str]:
|
|
25
|
+
"""Extract username from user object."""
|
|
26
|
+
if not user_data:
|
|
27
|
+
return None
|
|
28
|
+
return user_data.get("login")
|
|
29
|
+
|
|
30
|
+
def _extract_labels(self, labels_data: List[Dict[str, Any]]) -> List[str]:
|
|
31
|
+
"""Extract label names from labels array."""
|
|
32
|
+
return [label.get("name", "") for label in labels_data if label.get("name")]
|
|
33
|
+
|
|
34
|
+
def _extract_assignees(self, assignees_data: List[Dict[str, Any]]) -> List[str]:
|
|
35
|
+
"""Extract assignee usernames from assignees array."""
|
|
36
|
+
return [
|
|
37
|
+
assignee.get("login", "")
|
|
38
|
+
for assignee in assignees_data
|
|
39
|
+
if assignee.get("login")
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
def _extract_milestone(self, milestone_data: Optional[Dict[str, Any]]) -> Optional[str]:
|
|
43
|
+
"""Extract milestone title."""
|
|
44
|
+
if not milestone_data:
|
|
45
|
+
return None
|
|
46
|
+
return milestone_data.get("title")
|
|
47
|
+
|
|
48
|
+
def transform_issue(self, repo_data: Dict[str, Any], issue_data: Dict[str, Any],
|
|
49
|
+
comments_data: List[Dict[str, Any]]) -> Dict[str, Any]:
|
|
50
|
+
"""Transform issue data to the desired output format."""
|
|
51
|
+
|
|
52
|
+
issue = issue_data["issue"]
|
|
53
|
+
comments = issue_data["comments"]
|
|
54
|
+
|
|
55
|
+
# Transform repository info
|
|
56
|
+
repository_info = {
|
|
57
|
+
"owner": repo_data.get("owner", {}).get("login", ""),
|
|
58
|
+
"name": repo_data.get("name", ""),
|
|
59
|
+
"full_name": repo_data.get("full_name", "")
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Transform issue info
|
|
63
|
+
issue_info = {
|
|
64
|
+
"id": issue.get("id"),
|
|
65
|
+
"number": issue.get("number"),
|
|
66
|
+
"author": self._extract_user_login(issue.get("user")),
|
|
67
|
+
"state": issue.get("state"),
|
|
68
|
+
"title": issue.get("title", ""),
|
|
69
|
+
"body": issue.get("body", ""),
|
|
70
|
+
"labels": self._extract_labels(issue.get("labels", [])),
|
|
71
|
+
"assignee": self._extract_user_login(issue.get("assignee")),
|
|
72
|
+
"assignees": self._extract_assignees(issue.get("assignees", [])),
|
|
73
|
+
"milestone": self._extract_milestone(issue.get("milestone")),
|
|
74
|
+
"created_date": self._parse_datetime(issue.get("created_at")),
|
|
75
|
+
"updated_date": self._parse_datetime(issue.get("updated_at")),
|
|
76
|
+
"closed_date": self._parse_datetime(issue.get("closed_at"))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Transform comments
|
|
80
|
+
transformed_comments = []
|
|
81
|
+
for comment in comments:
|
|
82
|
+
transformed_comment = {
|
|
83
|
+
"id": comment.get("id"),
|
|
84
|
+
"author": self._extract_user_login(comment.get("user")),
|
|
85
|
+
"body": comment.get("body", ""),
|
|
86
|
+
"created_date": self._parse_datetime(comment.get("created_at")),
|
|
87
|
+
"updated_date": self._parse_datetime(comment.get("updated_at"))
|
|
88
|
+
}
|
|
89
|
+
transformed_comments.append(transformed_comment)
|
|
90
|
+
|
|
91
|
+
# Export metadata
|
|
92
|
+
export_metadata = {
|
|
93
|
+
"exported_at": datetime.now().isoformat(),
|
|
94
|
+
"tool_version": self.tool_version
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
"repository": repository_info,
|
|
99
|
+
"issue": issue_info,
|
|
100
|
+
"comments": transformed_comments,
|
|
101
|
+
"export_metadata": export_metadata
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
def transform_batch(self, repo_data: Dict[str, Any],
|
|
105
|
+
issues_with_comments: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
106
|
+
"""Transform a batch of issues with comments."""
|
|
107
|
+
transformed_issues = []
|
|
108
|
+
|
|
109
|
+
for issue_data in issues_with_comments:
|
|
110
|
+
transformed_issue = self.transform_issue(repo_data, issue_data, issue_data["comments"])
|
|
111
|
+
transformed_issues.append(transformed_issue)
|
|
112
|
+
|
|
113
|
+
return transformed_issues
|
|
114
|
+
|
|
115
|
+
def get_issue_updated_datetime(self, issue_data: Dict[str, Any]) -> datetime:
|
|
116
|
+
"""Extract issue updated datetime for comparison purposes."""
|
|
117
|
+
updated_str = issue_data.get("updated_at")
|
|
118
|
+
if not updated_str:
|
|
119
|
+
# Return timezone-aware minimum datetime
|
|
120
|
+
from datetime import timezone
|
|
121
|
+
return datetime.min.replace(tzinfo=timezone.utc)
|
|
122
|
+
|
|
123
|
+
try:
|
|
124
|
+
return datetime.fromisoformat(updated_str.replace('Z', '+00:00'))
|
|
125
|
+
except Exception:
|
|
126
|
+
# Return timezone-aware minimum datetime on error
|
|
127
|
+
from datetime import timezone
|
|
128
|
+
return datetime.min.replace(tzinfo=timezone.utc)
|
|
129
|
+
|
|
130
|
+
def create_export_summary(self, repo_data: Dict[str, Any],
|
|
131
|
+
exported_count: int, skipped_count: int,
|
|
132
|
+
error_count: int) -> Dict[str, Any]:
|
|
133
|
+
"""Create export summary data."""
|
|
134
|
+
return {
|
|
135
|
+
"repository": {
|
|
136
|
+
"owner": repo_data.get("owner", {}).get("login", ""),
|
|
137
|
+
"name": repo_data.get("name", ""),
|
|
138
|
+
"full_name": repo_data.get("full_name", "")
|
|
139
|
+
},
|
|
140
|
+
"export_summary": {
|
|
141
|
+
"exported_count": exported_count,
|
|
142
|
+
"skipped_count": skipped_count,
|
|
143
|
+
"error_count": error_count,
|
|
144
|
+
"total_processed": exported_count + skipped_count + error_count,
|
|
145
|
+
"exported_at": datetime.now().isoformat(),
|
|
146
|
+
"tool_version": self.tool_version
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: github-issue-exporter
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Export GitHub issues to individual JSON files with incremental updates and credential management
|
|
5
|
+
Project-URL: Homepage, https://github.com/Beep-Boop-Digital/github-issue-exporter
|
|
6
|
+
Project-URL: Repository, https://github.com/Beep-Boop-Digital/github-issue-exporter
|
|
7
|
+
Project-URL: Issues, https://github.com/Beep-Boop-Digital/github-issue-exporter/issues
|
|
8
|
+
Author-email: Adam McKay <adam@beepboop.digital>
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Requires-Dist: cryptography>=45.0.3
|
|
11
|
+
Requires-Dist: httpx>=0.28.1
|
|
12
|
+
Requires-Dist: pydantic>=2.11.5
|
|
13
|
+
Requires-Dist: rich>=14.0.0
|
|
14
|
+
Requires-Dist: typer>=0.16.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# GitHub Issue Exporter
|
|
18
|
+
|
|
19
|
+
A command-line tool that exports GitHub issues to individual JSON files, with incremental updates and credential management. Supports multiple repositories with per-repo configuration.
|
|
20
|
+
|
|
21
|
+
Authored by Claude Code.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **Incremental Updates**: Only exports issues that have been modified since last export
|
|
26
|
+
- **Multiple Repositories**: Process multiple repositories concurrently
|
|
27
|
+
- **Secure Credential Storage**: Encrypted storage of GitHub tokens
|
|
28
|
+
- **Rich Progress Display**: Beautiful progress bars and status updates
|
|
29
|
+
- **Flexible Configuration**: Per-repository settings and global configuration
|
|
30
|
+
- **Comprehensive Export**: Includes issue metadata, comments, labels, and assignees
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install with uv
|
|
36
|
+
uv tool install github-issue-exporter
|
|
37
|
+
|
|
38
|
+
# Or install in development mode
|
|
39
|
+
uv pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Export issues from a single repository
|
|
46
|
+
github-issue-exporter owner/repo
|
|
47
|
+
|
|
48
|
+
# Export from multiple repositories
|
|
49
|
+
github-issue-exporter owner/repo1,owner/repo2,owner/repo3
|
|
50
|
+
|
|
51
|
+
# Custom output directory
|
|
52
|
+
github-issue-exporter owner/repo --output /path/to/exports
|
|
53
|
+
|
|
54
|
+
# Force re-export (ignore timestamps)
|
|
55
|
+
github-issue-exporter owner/repo --force
|
|
56
|
+
|
|
57
|
+
# Export only open issues
|
|
58
|
+
github-issue-exporter owner/repo --state open
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Authentication
|
|
62
|
+
|
|
63
|
+
The tool will automatically prompt for a GitHub Personal Access Token when needed. You can create one at: https://github.com/settings/tokens
|
|
64
|
+
|
|
65
|
+
Required scopes:
|
|
66
|
+
- `repo` (for private repositories)
|
|
67
|
+
- `public_repo` (for public repositories)
|
|
68
|
+
|
|
69
|
+
Tokens are stored securely using encryption and can be managed per-repository.
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# View current configuration
|
|
75
|
+
github-issue-exporter config --show
|
|
76
|
+
|
|
77
|
+
# Clear stored authentication
|
|
78
|
+
github-issue-exporter config --clear-auth owner/repo
|
|
79
|
+
|
|
80
|
+
# Set default output directory
|
|
81
|
+
github-issue-exporter config --set-output /path/to/exports
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Output Format
|
|
85
|
+
|
|
86
|
+
Issues are exported as individual JSON files with the following structure:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"repository": {
|
|
91
|
+
"owner": "string",
|
|
92
|
+
"name": "string",
|
|
93
|
+
"full_name": "string"
|
|
94
|
+
},
|
|
95
|
+
"issue": {
|
|
96
|
+
"id": "number",
|
|
97
|
+
"number": "number",
|
|
98
|
+
"author": "string",
|
|
99
|
+
"state": "string",
|
|
100
|
+
"title": "string",
|
|
101
|
+
"body": "string",
|
|
102
|
+
"labels": ["string"],
|
|
103
|
+
"assignee": "string|null",
|
|
104
|
+
"assignees": ["string"],
|
|
105
|
+
"milestone": "string|null",
|
|
106
|
+
"created_date": "iso_string",
|
|
107
|
+
"updated_date": "iso_string",
|
|
108
|
+
"closed_date": "iso_string|null"
|
|
109
|
+
},
|
|
110
|
+
"comments": [
|
|
111
|
+
{
|
|
112
|
+
"id": "number",
|
|
113
|
+
"author": "string",
|
|
114
|
+
"body": "string",
|
|
115
|
+
"created_date": "iso_string",
|
|
116
|
+
"updated_date": "iso_string"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"export_metadata": {
|
|
120
|
+
"exported_at": "iso_string",
|
|
121
|
+
"tool_version": "string"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## File Organization
|
|
127
|
+
|
|
128
|
+
Files are organized by repository and issue state:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
exports/
|
|
132
|
+
owner1/
|
|
133
|
+
repo1/
|
|
134
|
+
open/
|
|
135
|
+
1-first-issue-title.json
|
|
136
|
+
3-another-open-issue.json
|
|
137
|
+
...
|
|
138
|
+
closed/
|
|
139
|
+
2-closed-issue-title.json
|
|
140
|
+
4-resolved-issue.json
|
|
141
|
+
...
|
|
142
|
+
owner2/
|
|
143
|
+
repo2/
|
|
144
|
+
open/
|
|
145
|
+
1-some-open-issue.json
|
|
146
|
+
closed/
|
|
147
|
+
2-some-closed-issue.json
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Key Features:**
|
|
151
|
+
- Issues are organized into `open` and `closed` subdirectories based on their current state
|
|
152
|
+
- Filenames use the issue number (not internal ID) for easier identification
|
|
153
|
+
- When an issue state changes, the file is automatically moved to the appropriate directory
|
|
154
|
+
|
|
155
|
+
## Commands
|
|
156
|
+
|
|
157
|
+
### export
|
|
158
|
+
Export GitHub issues to JSON files.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
github-issue-exporter export [OPTIONS] REPOSITORIES
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Options:
|
|
165
|
+
- `--output, -o`: Output directory (default: ./exports)
|
|
166
|
+
- `--force, -f`: Force re-export, ignoring timestamps
|
|
167
|
+
- `--state, -s`: Issue state (open, closed, all)
|
|
168
|
+
- `--no-comments`: Skip exporting comments
|
|
169
|
+
- `--concurrent, -c`: Max concurrent repositories (1-10)
|
|
170
|
+
|
|
171
|
+
### cleanup
|
|
172
|
+
Remove files for issues that no longer exist.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
github-issue-exporter cleanup [OPTIONS] REPOSITORY
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### config
|
|
179
|
+
Manage configuration and credentials.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
github-issue-exporter config [OPTIONS]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### --version
|
|
186
|
+
Show version information.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
github-issue-exporter --version
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Requirements
|
|
193
|
+
|
|
194
|
+
- Python 3.11+
|
|
195
|
+
- GitHub Personal Access Token (for private repos or higher rate limits)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
github_issue_exporter/__init__.py,sha256=0us9vrSLKQDN2I01NaqqptTBtXQhqLUD8vQb7TS5I_g,547
|
|
2
|
+
github_issue_exporter/__main__.py,sha256=h3IdlvGxz8Ytcij685W1QqNDavJyJISFqNDuWIZh0bo,118
|
|
3
|
+
github_issue_exporter/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
github_issue_exporter/cli/main.py,sha256=2d038NunSEItYKwfAXPWYHO7Wr1TqW0wVuFGl6__XoM,10527
|
|
5
|
+
github_issue_exporter/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
github_issue_exporter/core/auth.py,sha256=zfHGdGLYhB266DwFTjAT4nElGwEi8F72jI6fFCX4DlA,8435
|
|
7
|
+
github_issue_exporter/core/config.py,sha256=ZRE66y23IyeV2qmndORro49eVBX48CEzhsfRqYKwWMo,9059
|
|
8
|
+
github_issue_exporter/core/export_engine.py,sha256=B4bOcjI-ZtX7Zpllct40ZAdLK1AwX-dJh-KQbdVfNKQ,16343
|
|
9
|
+
github_issue_exporter/core/filesystem.py,sha256=UWoQw-N-LQYgOmmo8oBRFUpUFGQcFqgUTP6BNSCYs4o,9772
|
|
10
|
+
github_issue_exporter/core/github_client.py,sha256=rt02smX8qiMhHFlDdzdOYkqwnwGE52lYXTmFJeq-ERk,13365
|
|
11
|
+
github_issue_exporter/core/transformer.py,sha256=09KHWfs4LDbammfVpn1i_k-ZYATKpPYcm6YyxfMhnyk,6069
|
|
12
|
+
github_issue_exporter-0.0.1.dist-info/METADATA,sha256=n0n3JORoh-vaaF18t4IAw8OnmHFTZj2hk57HrNWaWe8,5039
|
|
13
|
+
github_issue_exporter-0.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
github_issue_exporter-0.0.1.dist-info/entry_points.txt,sha256=VDWP5D0RNm-cxxLagYS-oqyJq8v-b-sT67PNK7J7-cM,77
|
|
15
|
+
github_issue_exporter-0.0.1.dist-info/RECORD,,
|