esys-gitlog 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.
- esys_gitlog/__init__.py +3 -0
- esys_gitlog/__main__.py +6 -0
- esys_gitlog/app.py +215 -0
- esys_gitlog/cli.py +323 -0
- esys_gitlog/config.py +202 -0
- esys_gitlog/detection.py +145 -0
- esys_gitlog/display.py +82 -0
- esys_gitlog/git_adapter.py +370 -0
- esys_gitlog/identifiers.py +46 -0
- esys_gitlog/interpret.py +308 -0
- esys_gitlog/links.py +87 -0
- esys_gitlog/model.py +138 -0
- esys_gitlog/pager.py +106 -0
- esys_gitlog/pipeline.py +44 -0
- esys_gitlog/preferences.py +380 -0
- esys_gitlog/qa.py +196 -0
- esys_gitlog/render.py +372 -0
- esys_gitlog/report.py +117 -0
- esys_gitlog/tool_paths.py +62 -0
- esys_gitlog-0.1.0.dist-info/METADATA +77 -0
- esys_gitlog-0.1.0.dist-info/RECORD +25 -0
- esys_gitlog-0.1.0.dist-info/WHEEL +5 -0
- esys_gitlog-0.1.0.dist-info/entry_points.txt +2 -0
- esys_gitlog-0.1.0.dist-info/licenses/LICENSE.txt +18 -0
- esys_gitlog-0.1.0.dist-info/top_level.txt +1 -0
esys_gitlog/render.py
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
"""Rich human terminal presentation.
|
|
2
|
+
|
|
3
|
+
Commit text is untrusted. Escape it, or disable markup, before printing.
|
|
4
|
+
Human lines use the same display selection as the browser (not the raw subject).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
from typing import Literal
|
|
11
|
+
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
from rich.markup import escape
|
|
14
|
+
from rich.text import Text
|
|
15
|
+
|
|
16
|
+
from esys_gitlog.model import CommitResult, DisplaySelection
|
|
17
|
+
from esys_gitlog.pager import ScreenPager
|
|
18
|
+
from esys_gitlog.preferences import DEFAULT_REF_ID_WIDTH, DEFAULT_TYPE_WIDTH
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def default_console() -> Console:
|
|
22
|
+
"""Human console; honor FORCE_COLOR so VS Code ConPTY still gets ANSI.
|
|
23
|
+
|
|
24
|
+
FORCE_COLOR wins over NO_COLOR when both are set (common under agents/CI).
|
|
25
|
+
Pass ``no_color=False`` so Rich does not re-apply NO_COLOR from the environment.
|
|
26
|
+
"""
|
|
27
|
+
force = os.environ.get("FORCE_COLOR", "").strip() not in ("", "0")
|
|
28
|
+
if force:
|
|
29
|
+
return Console(
|
|
30
|
+
force_terminal=True,
|
|
31
|
+
color_system="truecolor",
|
|
32
|
+
no_color=False,
|
|
33
|
+
)
|
|
34
|
+
if os.environ.get("NO_COLOR", "").strip() != "":
|
|
35
|
+
return Console(no_color=True)
|
|
36
|
+
return Console()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
DiagLevel = Literal["error", "warning", "clean"]
|
|
40
|
+
DETAIL_INDENT = " "
|
|
41
|
+
# Prefer emoji with built-in fills: Windows consoles often ignore ANSI on these
|
|
42
|
+
# glyphs, so red vs yellow must come from the character itself.
|
|
43
|
+
SEVERITY_MARK_ERROR = "\u274c" # ❌ (2 terminal cells)
|
|
44
|
+
SEVERITY_MARK_WARNING = "\u26a0\ufe0f" # ⚠️ (2 terminal cells)
|
|
45
|
+
SEVERITY_MARK = SEVERITY_MARK_WARNING # backward-compatible alias
|
|
46
|
+
# Emoji marks are width 2; pad clean so SHA columns line up (mark + gap = 3).
|
|
47
|
+
SEVERITY_PREFIX_CLEAN = " "
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def severity_mark(level: DiagLevel) -> str:
|
|
51
|
+
if level == "error":
|
|
52
|
+
return SEVERITY_MARK_ERROR
|
|
53
|
+
if level == "warning":
|
|
54
|
+
return SEVERITY_MARK_WARNING
|
|
55
|
+
return " "
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def severity_prefix(level: DiagLevel) -> str:
|
|
59
|
+
"""Severity column including trailing gap (always 3 terminal cells)."""
|
|
60
|
+
if level == "error":
|
|
61
|
+
return f"{SEVERITY_MARK_ERROR} "
|
|
62
|
+
if level == "warning":
|
|
63
|
+
return f"{SEVERITY_MARK_WARNING} "
|
|
64
|
+
return SEVERITY_PREFIX_CLEAN
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def safe_text(value: str) -> str:
|
|
68
|
+
"""Escape untrusted commit text for Rich markup."""
|
|
69
|
+
return escape(value)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def diagnostic_level(result: CommitResult) -> DiagLevel:
|
|
73
|
+
if any(item.severity == "error" for item in result.diagnostics):
|
|
74
|
+
return "error"
|
|
75
|
+
if result.diagnostics:
|
|
76
|
+
return "warning"
|
|
77
|
+
return "clean"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def format_type_scope(display: DisplaySelection) -> str:
|
|
81
|
+
"""``feat``, ``feat(api)``, or ``feat(api)!`` when breaking."""
|
|
82
|
+
if not display.type:
|
|
83
|
+
return ""
|
|
84
|
+
text = display.type
|
|
85
|
+
if display.scope:
|
|
86
|
+
text = f"{text}({display.scope})"
|
|
87
|
+
if display.breaking:
|
|
88
|
+
text = f"{text}!"
|
|
89
|
+
return text
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def format_refs_column(ref_ids: list[str], width: int) -> str | None:
|
|
93
|
+
"""Fixed-width refs field for column alignment.
|
|
94
|
+
|
|
95
|
+
When ``width > 0``, always returns a string of exactly ``width`` characters
|
|
96
|
+
(space-padded or truncated) so the conventional type starts at one column.
|
|
97
|
+
When ``width <= 0``, returns the joined ids only if present (legacy layout).
|
|
98
|
+
"""
|
|
99
|
+
joined = " ".join(ref_ids)
|
|
100
|
+
if width <= 0:
|
|
101
|
+
return joined or None
|
|
102
|
+
if len(joined) > width:
|
|
103
|
+
return joined[:width]
|
|
104
|
+
return joined.ljust(width)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def format_type_column(type_scope: str, width: int) -> str | None:
|
|
108
|
+
"""Minimum-width Type(Scope)[!] field for title alignment.
|
|
109
|
+
|
|
110
|
+
When ``width > 0``, pads with spaces up to ``width`` but never truncates a
|
|
111
|
+
longer token (and still reserves a blank column when type is missing).
|
|
112
|
+
When ``width <= 0``, returns the token only if present.
|
|
113
|
+
"""
|
|
114
|
+
if width <= 0:
|
|
115
|
+
return type_scope or None
|
|
116
|
+
if len(type_scope) >= width:
|
|
117
|
+
return type_scope
|
|
118
|
+
return type_scope.ljust(width)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def format_human_line_parts(
|
|
122
|
+
commit_id: str,
|
|
123
|
+
result: CommitResult,
|
|
124
|
+
subject: str,
|
|
125
|
+
*,
|
|
126
|
+
ref_id_width: int = DEFAULT_REF_ID_WIDTH,
|
|
127
|
+
type_width: int = DEFAULT_TYPE_WIDTH,
|
|
128
|
+
show_id: bool = True,
|
|
129
|
+
show_conventional: bool = True,
|
|
130
|
+
) -> tuple[str, ...]:
|
|
131
|
+
"""Plain-text fields after the severity marker (untrusted; escape before Rich).
|
|
132
|
+
|
|
133
|
+
``show_id`` controls the ticket / Jira reference column (not the commit SHA).
|
|
134
|
+
"""
|
|
135
|
+
display = result.display
|
|
136
|
+
parts: list[str] = [commit_id[:12]]
|
|
137
|
+
if display is not None:
|
|
138
|
+
ref_ids = [ref.id for ref in display.refs if ref.id]
|
|
139
|
+
if show_id:
|
|
140
|
+
refs_field = format_refs_column(ref_ids, ref_id_width)
|
|
141
|
+
if refs_field is not None:
|
|
142
|
+
parts.append(refs_field)
|
|
143
|
+
type_raw = format_type_scope(display) if show_conventional else ""
|
|
144
|
+
if show_conventional:
|
|
145
|
+
type_field = format_type_column(type_raw, type_width)
|
|
146
|
+
if type_field is not None:
|
|
147
|
+
parts.append(type_field)
|
|
148
|
+
title = (display.title or "").strip()
|
|
149
|
+
if title:
|
|
150
|
+
parts.append(title)
|
|
151
|
+
elif not ref_ids and not type_raw:
|
|
152
|
+
parts.append(subject if subject else "(empty subject)")
|
|
153
|
+
else:
|
|
154
|
+
parts.append(subject if subject else "(empty subject)")
|
|
155
|
+
return tuple(parts)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def format_human_line(
|
|
159
|
+
commit_id: str,
|
|
160
|
+
result: CommitResult,
|
|
161
|
+
subject: str,
|
|
162
|
+
*,
|
|
163
|
+
ref_id_width: int = DEFAULT_REF_ID_WIDTH,
|
|
164
|
+
type_width: int = DEFAULT_TYPE_WIDTH,
|
|
165
|
+
show_id: bool = True,
|
|
166
|
+
show_conventional: bool = True,
|
|
167
|
+
) -> str:
|
|
168
|
+
"""Plain one-line summary (tests / non-Rich). Marker is ``❌`` / ``⚠️`` / pad."""
|
|
169
|
+
level = diagnostic_level(result)
|
|
170
|
+
body = " ".join(
|
|
171
|
+
format_human_line_parts(
|
|
172
|
+
commit_id,
|
|
173
|
+
result,
|
|
174
|
+
subject,
|
|
175
|
+
ref_id_width=ref_id_width,
|
|
176
|
+
type_width=type_width,
|
|
177
|
+
show_id=show_id,
|
|
178
|
+
show_conventional=show_conventional,
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
return f"{severity_prefix(level)}{body}"
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def extract_commit_body(message: str | None, subject: str) -> str:
|
|
185
|
+
"""Body text after the subject (trailers included). Empty when absent."""
|
|
186
|
+
if not message:
|
|
187
|
+
return ""
|
|
188
|
+
text = message
|
|
189
|
+
if subject and text.startswith(subject):
|
|
190
|
+
text = text[len(subject) :]
|
|
191
|
+
return text.lstrip("\n")
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def format_author_line(result: CommitResult) -> str | None:
|
|
195
|
+
name = (result.author_name or "").strip()
|
|
196
|
+
email = (result.author_email or "").strip()
|
|
197
|
+
if name and email:
|
|
198
|
+
return f"{name} <{email}>"
|
|
199
|
+
if name:
|
|
200
|
+
return name
|
|
201
|
+
if email:
|
|
202
|
+
return f"<{email}>"
|
|
203
|
+
return None
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def format_detail_lines(
|
|
207
|
+
result: CommitResult,
|
|
208
|
+
subject: str,
|
|
209
|
+
*,
|
|
210
|
+
show_author: bool = False,
|
|
211
|
+
show_date: bool = False,
|
|
212
|
+
show_body: bool = False,
|
|
213
|
+
) -> tuple[str, ...]:
|
|
214
|
+
"""Indented follow-on lines (author, date, body). Each line starts with 4 spaces."""
|
|
215
|
+
lines: list[str] = []
|
|
216
|
+
if show_author:
|
|
217
|
+
author = format_author_line(result)
|
|
218
|
+
if author is not None:
|
|
219
|
+
lines.append(f"{DETAIL_INDENT}{author}")
|
|
220
|
+
if show_date:
|
|
221
|
+
date = (result.authored_date or "").strip()
|
|
222
|
+
if date:
|
|
223
|
+
lines.append(f"{DETAIL_INDENT}{date}")
|
|
224
|
+
if show_body:
|
|
225
|
+
body = extract_commit_body(result.message, subject)
|
|
226
|
+
for body_line in body.splitlines():
|
|
227
|
+
lines.append(f"{DETAIL_INDENT}{body_line}")
|
|
228
|
+
return tuple(lines)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def render_human_line(
|
|
232
|
+
commit_id: str,
|
|
233
|
+
result: CommitResult,
|
|
234
|
+
subject: str,
|
|
235
|
+
*,
|
|
236
|
+
ref_id_width: int = DEFAULT_REF_ID_WIDTH,
|
|
237
|
+
type_width: int = DEFAULT_TYPE_WIDTH,
|
|
238
|
+
show_id: bool = True,
|
|
239
|
+
show_conventional: bool = True,
|
|
240
|
+
) -> Text:
|
|
241
|
+
"""Rich line: ``❌`` (error) / ``⚠️`` (warning); type keeps its own style.
|
|
242
|
+
|
|
243
|
+
Breaking ``!`` stays on the type token (``feat(api)!``).
|
|
244
|
+
"""
|
|
245
|
+
level = diagnostic_level(result)
|
|
246
|
+
parts = format_human_line_parts(
|
|
247
|
+
commit_id,
|
|
248
|
+
result,
|
|
249
|
+
subject,
|
|
250
|
+
ref_id_width=ref_id_width,
|
|
251
|
+
type_width=type_width,
|
|
252
|
+
show_id=show_id,
|
|
253
|
+
show_conventional=show_conventional,
|
|
254
|
+
)
|
|
255
|
+
# parts: sha, [refs], [type[(scope)][!]], [title…]
|
|
256
|
+
display = result.display
|
|
257
|
+
type_raw = format_type_scope(display) if display is not None and show_conventional else ""
|
|
258
|
+
type_field = format_type_column(type_raw, type_width) if show_conventional else None
|
|
259
|
+
index = 0
|
|
260
|
+
segments: list[tuple[str, str | None]] = []
|
|
261
|
+
|
|
262
|
+
if level == "error":
|
|
263
|
+
segments.append((severity_prefix(level), "bold red"))
|
|
264
|
+
elif level == "warning":
|
|
265
|
+
segments.append((severity_prefix(level), "bold yellow"))
|
|
266
|
+
else:
|
|
267
|
+
segments.append((severity_prefix(level), None))
|
|
268
|
+
|
|
269
|
+
def add_field(text: str, style: str | None) -> None:
|
|
270
|
+
nonlocal index
|
|
271
|
+
if index:
|
|
272
|
+
segments.append((" ", None))
|
|
273
|
+
segments.append((safe_text(text), style))
|
|
274
|
+
index += 1
|
|
275
|
+
|
|
276
|
+
if not parts:
|
|
277
|
+
return Text.assemble(*segments)
|
|
278
|
+
|
|
279
|
+
add_field(parts[0], "dim") # commit SHA always
|
|
280
|
+
rest = list(parts[1:])
|
|
281
|
+
if type_field and type_field in rest:
|
|
282
|
+
type_at = rest.index(type_field)
|
|
283
|
+
for item in rest[:type_at]:
|
|
284
|
+
add_field(item, "cyan") # Jira / ticket refs
|
|
285
|
+
# Color the type token; leave trailing pad unstyled.
|
|
286
|
+
if index:
|
|
287
|
+
segments.append((" ", None))
|
|
288
|
+
if type_raw:
|
|
289
|
+
segments.append((safe_text(type_raw), "bold cyan"))
|
|
290
|
+
pad = type_field[len(type_raw) :]
|
|
291
|
+
if pad:
|
|
292
|
+
segments.append((pad, None))
|
|
293
|
+
else:
|
|
294
|
+
segments.append((type_field, None))
|
|
295
|
+
index += 1
|
|
296
|
+
for item in rest[type_at + 1 :]:
|
|
297
|
+
add_field(item, None) # cleaned title
|
|
298
|
+
else:
|
|
299
|
+
for item in rest:
|
|
300
|
+
style = None
|
|
301
|
+
if show_id and display is not None:
|
|
302
|
+
refs_field = format_refs_column(
|
|
303
|
+
[ref.id for ref in display.refs if ref.id],
|
|
304
|
+
ref_id_width,
|
|
305
|
+
)
|
|
306
|
+
if refs_field is not None and item == refs_field:
|
|
307
|
+
style = "cyan"
|
|
308
|
+
add_field(item, style)
|
|
309
|
+
|
|
310
|
+
return Text.assemble(*segments)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
def render_history(
|
|
314
|
+
rows: list[tuple[str, CommitResult, str]],
|
|
315
|
+
console: Console | None = None,
|
|
316
|
+
*,
|
|
317
|
+
ref_id_width: int = DEFAULT_REF_ID_WIDTH,
|
|
318
|
+
type_width: int = DEFAULT_TYPE_WIDTH,
|
|
319
|
+
show_author: bool = False,
|
|
320
|
+
show_date: bool = False,
|
|
321
|
+
show_body: bool = False,
|
|
322
|
+
show_id: bool = True,
|
|
323
|
+
show_conventional: bool = True,
|
|
324
|
+
use_pager: bool | None = None,
|
|
325
|
+
) -> None:
|
|
326
|
+
"""Render analyzed commits for a person. Not used on the JSON path.
|
|
327
|
+
|
|
328
|
+
Each row is ``(commit_id, result, subject)``. Optional detail lines are
|
|
329
|
+
indented with four spaces.
|
|
330
|
+
|
|
331
|
+
When ``use_pager`` is True, or None and stdout is a TTY, output goes through
|
|
332
|
+
a screenful pager (Enter/Space = next page, ``q`` = quit).
|
|
333
|
+
"""
|
|
334
|
+
out = console if console is not None else default_console()
|
|
335
|
+
if not rows:
|
|
336
|
+
out.print("esys-gitlog: no commits")
|
|
337
|
+
return
|
|
338
|
+
|
|
339
|
+
def emit() -> None:
|
|
340
|
+
for index, (commit_id, result, subject) in enumerate(rows):
|
|
341
|
+
out.print(
|
|
342
|
+
render_human_line(
|
|
343
|
+
commit_id,
|
|
344
|
+
result,
|
|
345
|
+
subject,
|
|
346
|
+
ref_id_width=ref_id_width,
|
|
347
|
+
type_width=type_width,
|
|
348
|
+
show_id=show_id,
|
|
349
|
+
show_conventional=show_conventional,
|
|
350
|
+
)
|
|
351
|
+
)
|
|
352
|
+
details = format_detail_lines(
|
|
353
|
+
result,
|
|
354
|
+
subject,
|
|
355
|
+
show_author=show_author,
|
|
356
|
+
show_date=show_date,
|
|
357
|
+
show_body=show_body,
|
|
358
|
+
)
|
|
359
|
+
for detail in details:
|
|
360
|
+
# No markup/highlight — Rich's default highlighter colors emails
|
|
361
|
+
# and ISO dates, which makes author/date lines hard to read.
|
|
362
|
+
out.print(detail, markup=False, highlight=False)
|
|
363
|
+
# Blank line between multi-line commit blocks (not after the last).
|
|
364
|
+
if details and index < len(rows) - 1:
|
|
365
|
+
out.print()
|
|
366
|
+
|
|
367
|
+
page = out.is_terminal if use_pager is None else use_pager
|
|
368
|
+
if page:
|
|
369
|
+
with out.pager(pager=ScreenPager(), styles=True):
|
|
370
|
+
emit()
|
|
371
|
+
else:
|
|
372
|
+
emit()
|
esys_gitlog/report.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Serialize the QA report JSON document.
|
|
2
|
+
|
|
3
|
+
The structured report is written to stdout only. Rich markup, color, progress,
|
|
4
|
+
and tracebacks stay off that stream.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from typing import Any, TextIO
|
|
11
|
+
|
|
12
|
+
from esys_gitlog.model import CommitResult
|
|
13
|
+
|
|
14
|
+
PRODUCER = "esys-gitlog-python"
|
|
15
|
+
CONTRACT_VERSION = "0"
|
|
16
|
+
INTERPRETATION_VERSION = "0"
|
|
17
|
+
QA_VERSION = "0"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def empty_report() -> dict[str, Any]:
|
|
21
|
+
"""Return a finished report with no commits.
|
|
22
|
+
|
|
23
|
+
Field names follow esys-gitlog-spec. An empty commits array is a completed
|
|
24
|
+
run with no commits, not a failure.
|
|
25
|
+
"""
|
|
26
|
+
return build_report([])
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def build_report(results: list[tuple[str, CommitResult]]) -> dict[str, Any]:
|
|
30
|
+
"""Build one report document from analyzed commits in ``git log`` order."""
|
|
31
|
+
commits: list[dict[str, Any]] = []
|
|
32
|
+
warnings = 0
|
|
33
|
+
errors = 0
|
|
34
|
+
for commit_id, result in results:
|
|
35
|
+
for diagnostic in result.diagnostics:
|
|
36
|
+
if diagnostic.severity == "warning":
|
|
37
|
+
warnings += 1
|
|
38
|
+
elif diagnostic.severity == "error":
|
|
39
|
+
errors += 1
|
|
40
|
+
commits.append(result.to_report_commit(commit_id))
|
|
41
|
+
return {
|
|
42
|
+
"contractVersion": CONTRACT_VERSION,
|
|
43
|
+
"interpretationVersion": INTERPRETATION_VERSION,
|
|
44
|
+
"qaVersion": QA_VERSION,
|
|
45
|
+
"producer": PRODUCER,
|
|
46
|
+
"summary": {
|
|
47
|
+
"commits": len(commits),
|
|
48
|
+
"warnings": warnings,
|
|
49
|
+
"errors": errors,
|
|
50
|
+
},
|
|
51
|
+
"commits": commits,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def write_report(stream: TextIO[str], document: dict[str, Any]) -> None:
|
|
56
|
+
"""Write one JSON document to ``stream`` and a trailing newline."""
|
|
57
|
+
json.dump(document, stream, indent=2, sort_keys=False)
|
|
58
|
+
stream.write("\n")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def write_stream_event(stream: TextIO[str], event: dict[str, Any]) -> None:
|
|
62
|
+
"""Write one NDJSON event line and flush."""
|
|
63
|
+
stream.write(json.dumps(event, sort_keys=False, ensure_ascii=False))
|
|
64
|
+
stream.write("\n")
|
|
65
|
+
stream.flush()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def stream_start_event() -> dict[str, Any]:
|
|
69
|
+
"""Header event for ``--json-stream``."""
|
|
70
|
+
return {
|
|
71
|
+
"type": "start",
|
|
72
|
+
"contractVersion": CONTRACT_VERSION,
|
|
73
|
+
"interpretationVersion": INTERPRETATION_VERSION,
|
|
74
|
+
"qaVersion": QA_VERSION,
|
|
75
|
+
"producer": PRODUCER,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def stream_commit_event(commit_id: str, result: CommitResult) -> dict[str, Any]:
|
|
80
|
+
"""Commit event: report commit fields plus ``type``."""
|
|
81
|
+
payload = result.to_report_commit(commit_id)
|
|
82
|
+
payload["type"] = "commit"
|
|
83
|
+
return payload
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def stream_end_event(
|
|
87
|
+
*,
|
|
88
|
+
commits: int,
|
|
89
|
+
warnings: int,
|
|
90
|
+
errors: int,
|
|
91
|
+
walk_finished: bool,
|
|
92
|
+
) -> dict[str, Any]:
|
|
93
|
+
"""Footer event for ``--json-stream``."""
|
|
94
|
+
return {
|
|
95
|
+
"type": "end",
|
|
96
|
+
"summary": {
|
|
97
|
+
"commits": commits,
|
|
98
|
+
"warnings": warnings,
|
|
99
|
+
"errors": errors,
|
|
100
|
+
},
|
|
101
|
+
"walkFinished": walk_finished,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def report_exit_code(document: dict[str, Any], *, walk_finished: bool = True) -> int:
|
|
106
|
+
"""Map a finished or stopped report to the spec exit code."""
|
|
107
|
+
if not walk_finished:
|
|
108
|
+
return 2
|
|
109
|
+
errors = int(document.get("summary", {}).get("errors", 0))
|
|
110
|
+
return 1 if errors else 0
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def stream_exit_code(*, errors: int, walk_finished: bool = True) -> int:
|
|
114
|
+
"""Map stream summary counters to the spec exit code."""
|
|
115
|
+
if not walk_finished:
|
|
116
|
+
return 2
|
|
117
|
+
return 1 if errors else 0
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Locate esys-gitlog preference roots (user / .tools / .tools_local)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
TOOL_ID = "esys-gitlog"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def user_tool_root() -> Path:
|
|
12
|
+
"""Platform user config directory for this tool."""
|
|
13
|
+
if os.name == "nt":
|
|
14
|
+
base = os.environ.get("APPDATA")
|
|
15
|
+
if base:
|
|
16
|
+
return Path(base) / "esys" / TOOL_ID
|
|
17
|
+
return Path.home() / "AppData" / "Roaming" / "esys" / TOOL_ID
|
|
18
|
+
# POSIX paths — covered on Linux CI; omitted from Windows coverage.
|
|
19
|
+
xdg = os.environ.get("XDG_CONFIG_HOME") # pragma: no cover
|
|
20
|
+
if xdg: # pragma: no cover
|
|
21
|
+
return Path(xdg) / "esys" / TOOL_ID
|
|
22
|
+
return Path.home() / ".config" / "esys" / TOOL_ID # pragma: no cover
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def user_preferences_path() -> Path:
|
|
26
|
+
return user_tool_root() / "config.json"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def find_workspace_root(start: Path) -> Path | None:
|
|
30
|
+
"""Walk parents for a workspace marker (``.tools/esys`` or ``AGENTS.md``)."""
|
|
31
|
+
current = start.resolve()
|
|
32
|
+
if current.is_file():
|
|
33
|
+
current = current.parent
|
|
34
|
+
for candidate in (current, *current.parents):
|
|
35
|
+
if (candidate / ".tools" / "esys").is_dir():
|
|
36
|
+
return candidate
|
|
37
|
+
if (candidate / "AGENTS.md").is_file():
|
|
38
|
+
return candidate
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def repo_tools_root(workspace: Path) -> Path:
|
|
43
|
+
return workspace / ".tools" / "esys" / TOOL_ID
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def repo_tools_local_root(workspace: Path) -> Path:
|
|
47
|
+
return workspace / ".tools_local" / "esys" / TOOL_ID
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def preference_roots_low_to_high(cwd: Path) -> list[Path]:
|
|
51
|
+
"""Roots whose ``config.json`` may exist, user first then repo layers."""
|
|
52
|
+
roots = [user_tool_root()]
|
|
53
|
+
workspace = find_workspace_root(cwd)
|
|
54
|
+
if workspace is not None:
|
|
55
|
+
roots.append(repo_tools_root(workspace))
|
|
56
|
+
roots.append(repo_tools_local_root(workspace))
|
|
57
|
+
return roots
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def profile_search_roots_high_to_low(cwd: Path) -> list[Path]:
|
|
61
|
+
"""Roots to search for ``profiles/<name>.json`` (local wins)."""
|
|
62
|
+
return list(reversed(preference_roots_low_to_high(cwd)))
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: esys-gitlog
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python implementation of git elog
|
|
5
|
+
Author: Project maintainers
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE.txt
|
|
10
|
+
Requires-Dist: typer>=0.12
|
|
11
|
+
Requires-Dist: rich>=13.0
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
14
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
15
|
+
Requires-Dist: ruff>=0.8; extra == "dev"
|
|
16
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
17
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pre-commit>=3.0; extra == "dev"
|
|
19
|
+
Provides-Extra: standalone
|
|
20
|
+
Requires-Dist: pyinstaller>=6.0; extra == "standalone"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# esys-gitlog
|
|
24
|
+
|
|
25
|
+
Python implementation of `git elog`. The distribution name is `esys-gitlog`. The import package is `esys_gitlog`. The installed command is `git-elog`, so Git can run `git elog`.
|
|
26
|
+
|
|
27
|
+
The shared contract lives in `esys-gitlog-spec`. This repository carries that contract in Python. It does not define a second one.
|
|
28
|
+
|
|
29
|
+
## Smoke
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install .
|
|
33
|
+
git elog --help
|
|
34
|
+
git elog --json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`--json` writes one QA report document to stdout. The first skeleton returns an empty `commits` array.
|
|
38
|
+
|
|
39
|
+
## Release / publish
|
|
40
|
+
|
|
41
|
+
Tag-driven CI publishes to GitLab Package Registry, TestPyPI, then PyPI (Deckicorn-style ADR-0009 flow). See [docs/release-pipeline.md](docs/release-pipeline.md).
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
python scripts/publish_release.py --dry-run --bump patch
|
|
45
|
+
python scripts/build_package.py
|
|
46
|
+
python scripts/smoke_install_package.py --dist dist --expected-version 0.1.0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Preferences and profiles
|
|
50
|
+
|
|
51
|
+
Layered tool preferences (user → `.tools/esys/esys-gitlog/` → `.tools_local/…`)
|
|
52
|
+
and named profiles follow root SADR-0009 / SADR-0010 and contract CADR-0012.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git-elog --preferences path.json # preference overlay
|
|
56
|
+
git-elog --profile acme # built-in or profiles/acme.json
|
|
57
|
+
git-elog --config path/profile.json # one-off profile file
|
|
58
|
+
git-elog preferences detect # probe jira/gh/glab/git remote; write missing user keys
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Standalone binary (optional)
|
|
62
|
+
|
|
63
|
+
The primary install remains the wheel + `git-elog` console script. For a
|
|
64
|
+
frozen one-file binary (for example Cursor `esysGitlog.executablePath` without
|
|
65
|
+
a Python env on PATH):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python scripts/build_standalone.py
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Output: `dist/git-elog.exe` (Windows) or `dist/git-elog` (Linux/macOS). Build on
|
|
72
|
+
the OS you need — this does not cross-compile.
|
|
73
|
+
|
|
74
|
+
- [Architecture](docs/architecture/overview.md)
|
|
75
|
+
- [ADRs](docs/adr/INDEX.md)
|
|
76
|
+
- [ASRs](docs/asr/INDEX.md)
|
|
77
|
+
- [Implementation plan](plans/implementation.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
esys_gitlog/__init__.py,sha256=Zg8qfmzPXDESVoKcJkWlwSMcFWCoXiPkTeGZOycWR0Y,66
|
|
2
|
+
esys_gitlog/__main__.py,sha256=fCvGxVPynv2aDl1EnUUhPtSk1QtDF1-xCFD8P62F6X4,134
|
|
3
|
+
esys_gitlog/app.py,sha256=YOckBQHRAt1tyxPZOqTyl9qLisqUB4kwjVaxbLC2IK4,6985
|
|
4
|
+
esys_gitlog/cli.py,sha256=o33B3CKWFzUVLIHaN-jl5tCnD_KvyIacd94PDYiSrwM,10739
|
|
5
|
+
esys_gitlog/config.py,sha256=JtXpIqH_IqgbpfwanVNORzq38UQdhnbWyvbQROQ7d8w,6541
|
|
6
|
+
esys_gitlog/detection.py,sha256=noDQMJ2OiMyNdOk1b3siDXks7SIJaaLOCJfHpNuI15U,4732
|
|
7
|
+
esys_gitlog/display.py,sha256=A6K2koRk6uAzb4vIhIfWaATZdEAAfFn3e_2OO0ZCtMY,2816
|
|
8
|
+
esys_gitlog/git_adapter.py,sha256=3EVHg9t7r7nHLNiYfgLNFmGldL2NGOw6MuOhDdv3KCg,11369
|
|
9
|
+
esys_gitlog/identifiers.py,sha256=oBMs688fDioNQElepS7mdFewKK_Fc3ej9vZMiC250Ho,1349
|
|
10
|
+
esys_gitlog/interpret.py,sha256=pmqD4gusd84pYmeqiVbrFceQd5jqyI66negXU82Q7sw,9149
|
|
11
|
+
esys_gitlog/links.py,sha256=5iSQihabrQIY9gHE7UHLwVHOvnz2vN2cpaf3-Q3YAc4,2931
|
|
12
|
+
esys_gitlog/model.py,sha256=uPwsALtrFpc7O8tH_9l0b2vXKzXslceMBvsI48rCsW8,4533
|
|
13
|
+
esys_gitlog/pager.py,sha256=WINLfB6mqxyfWEQBZOlk2zqgAiZtool1tCpKERvh5yY,3150
|
|
14
|
+
esys_gitlog/pipeline.py,sha256=r_O1-XhQDWw7MrG3USve1m6zl7bfPMYIanXi9StqlcQ,1320
|
|
15
|
+
esys_gitlog/preferences.py,sha256=s4njLeqDPGcG8iWt7urXve2VFiKbL5DNVPXKAlISfIQ,13028
|
|
16
|
+
esys_gitlog/qa.py,sha256=05qwYrb4gIshR8I_MPnkWJJ8cC-39bsrbCmTb1ZUSrs,6456
|
|
17
|
+
esys_gitlog/render.py,sha256=ptBVp7CtiSaeE4QAsRxfU6n6ZGnEh2wpIOXsUoICv_0,12184
|
|
18
|
+
esys_gitlog/report.py,sha256=BSn7qbhUu35Rtamp1HKOvIjv6XH5re0gI4yEFv2kX9E,3407
|
|
19
|
+
esys_gitlog/tool_paths.py,sha256=HPS58GFgHEpaa5BVWM-uAsiAHvJJ1aYjZRPmHBt9PZE,2049
|
|
20
|
+
esys_gitlog-0.1.0.dist-info/licenses/LICENSE.txt,sha256=-AsrW2aWIOPzdrVud1Shx7gQp40pLQHWTfyHR3hctL8,1072
|
|
21
|
+
esys_gitlog-0.1.0.dist-info/METADATA,sha256=xOnkpcEzE6HOZw0KBtiOTim6tUTzbo1aP2XXNvBLQKs,2567
|
|
22
|
+
esys_gitlog-0.1.0.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
23
|
+
esys_gitlog-0.1.0.dist-info/entry_points.txt,sha256=eabmY3ym4ZYAfJFjH6OCcFaLTAjNNPBXIO4MSFdszP8,50
|
|
24
|
+
esys_gitlog-0.1.0.dist-info/top_level.txt,sha256=avwTurmCgyZz-PPBLXyDSfln4PjsEBg3GUnUN97NuH8,12
|
|
25
|
+
esys_gitlog-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 esys-gitlog-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
esys_gitlog
|