git-contribution-analyzer 0.8.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_contribution_analyzer/__init__.py +3 -0
- git_contribution_analyzer/adapters/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/__init__.py +1 -0
- git_contribution_analyzer/adapters/git/local_identity.py +51 -0
- git_contribution_analyzer/adapters/git/native_git.py +353 -0
- git_contribution_analyzer/adapters/git/pydriller_history.py +57 -0
- git_contribution_analyzer/adapters/git/repository_discovery.py +75 -0
- git_contribution_analyzer/adapters/gui/__init__.py +1 -0
- git_contribution_analyzer/adapters/gui/app.py +63 -0
- git_contribution_analyzer/adapters/gui/controller.py +1084 -0
- git_contribution_analyzer/adapters/gui/models/__init__.py +3 -0
- git_contribution_analyzer/adapters/gui/models/base_table.py +108 -0
- git_contribution_analyzer/adapters/gui/settings.py +53 -0
- git_contribution_analyzer/adapters/gui/task_runner.py +196 -0
- git_contribution_analyzer/adapters/llm/__init__.py +1 -0
- git_contribution_analyzer/adapters/llm/anthropic.py +52 -0
- git_contribution_analyzer/adapters/llm/base.py +142 -0
- git_contribution_analyzer/adapters/llm/cache.py +148 -0
- git_contribution_analyzer/adapters/llm/claude_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/codex_cli.py +52 -0
- git_contribution_analyzer/adapters/llm/command_base.py +153 -0
- git_contribution_analyzer/adapters/llm/mock.py +82 -0
- git_contribution_analyzer/adapters/llm/ollama.py +53 -0
- git_contribution_analyzer/adapters/llm/openai_compatible.py +61 -0
- git_contribution_analyzer/adapters/llm/registry.py +117 -0
- git_contribution_analyzer/adapters/mcp/__init__.py +13 -0
- git_contribution_analyzer/adapters/mcp/installer.py +175 -0
- git_contribution_analyzer/adapters/mcp/prompts_resources.py +218 -0
- git_contribution_analyzer/adapters/mcp/protocol.py +361 -0
- git_contribution_analyzer/adapters/mcp/server.py +52 -0
- git_contribution_analyzer/adapters/mcp/tools.py +621 -0
- git_contribution_analyzer/adapters/outcomes/__init__.py +1 -0
- git_contribution_analyzer/adapters/outcomes/yaml_loader.py +55 -0
- git_contribution_analyzer/adapters/outcomes/yaml_store.py +104 -0
- git_contribution_analyzer/adapters/reporting/__init__.py +1 -0
- git_contribution_analyzer/adapters/reporting/brag_markdown.py +115 -0
- git_contribution_analyzer/adapters/reporting/html_report.py +1413 -0
- git_contribution_analyzer/adapters/reporting/markdown.py +217 -0
- git_contribution_analyzer/adapters/reporting/portfolio_markdown.py +167 -0
- git_contribution_analyzer/adapters/reporting/recap_markdown.py +212 -0
- git_contribution_analyzer/adapters/reporting/resume_markdown.py +37 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_csv.py +117 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_markdown.py +90 -0
- git_contribution_analyzer/adapters/reporting/work_assessment_series_markdown.py +31 -0
- git_contribution_analyzer/adapters/storage/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/__init__.py +1 -0
- git_contribution_analyzer/adapters/storage/sqlite/analysis.py +708 -0
- git_contribution_analyzer/adapters/storage/sqlite/database.py +98 -0
- git_contribution_analyzer/adapters/storage/sqlite/git_index.py +482 -0
- git_contribution_analyzer/adapters/storage/sqlite/identity_merge.py +373 -0
- git_contribution_analyzer/adapters/storage/sqlite/llm_audit.py +109 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/env.py +34 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/script.py.mako +22 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0001_initial.py +51 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0002_git_index.py +146 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0003_analysis.py +79 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0004_llm_audit.py +69 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0005_run_types.py +42 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0006_identity_merges.py +83 -0
- git_contribution_analyzer/adapters/storage/sqlite/migrations/versions/0007_structural_baselines.py +173 -0
- git_contribution_analyzer/adapters/storage/sqlite/models.py +354 -0
- git_contribution_analyzer/adapters/storage/sqlite/structural_baseline.py +841 -0
- git_contribution_analyzer/adapters/workspace/__init__.py +1 -0
- git_contribution_analyzer/adapters/workspace/config.py +135 -0
- git_contribution_analyzer/adapters/workspace/git_exclude.py +32 -0
- git_contribution_analyzer/adapters/workspace/layout.py +40 -0
- git_contribution_analyzer/adapters/workspace/locks.py +27 -0
- git_contribution_analyzer/adapters/workspace/portfolio_workspace.py +380 -0
- git_contribution_analyzer/adapters/workspace/ranking_config.py +17 -0
- git_contribution_analyzer/application/__init__.py +1 -0
- git_contribution_analyzer/application/dto/__init__.py +19 -0
- git_contribution_analyzer/application/dto/gui.py +86 -0
- git_contribution_analyzer/application/dto/results.py +21 -0
- git_contribution_analyzer/application/facades/__init__.py +3 -0
- git_contribution_analyzer/application/facades/gui.py +568 -0
- git_contribution_analyzer/application/ports/__init__.py +22 -0
- git_contribution_analyzer/application/ports/cancellation.py +50 -0
- git_contribution_analyzer/application/ports/git_history.py +22 -0
- git_contribution_analyzer/application/ports/llm.py +44 -0
- git_contribution_analyzer/application/ports/portfolio_store.py +34 -0
- git_contribution_analyzer/application/ports/progress.py +43 -0
- git_contribution_analyzer/application/ports/structural_baseline.py +93 -0
- git_contribution_analyzer/application/services/__init__.py +1 -0
- git_contribution_analyzer/application/services/assessment_explanation.py +127 -0
- git_contribution_analyzer/application/services/default_person.py +61 -0
- git_contribution_analyzer/application/services/evidence_snapshot.py +64 -0
- git_contribution_analyzer/application/services/person_selection.py +88 -0
- git_contribution_analyzer/application/services/resume_generation.py +318 -0
- git_contribution_analyzer/application/services/semantic_enhancement.py +157 -0
- git_contribution_analyzer/application/services/time_boundaries.py +49 -0
- git_contribution_analyzer/application/use_cases/__init__.py +1 -0
- git_contribution_analyzer/application/use_cases/analyze_contributions.py +276 -0
- git_contribution_analyzer/application/use_cases/analyze_project.py +295 -0
- git_contribution_analyzer/application/use_cases/assess_portfolio.py +327 -0
- git_contribution_analyzer/application/use_cases/assess_work.py +602 -0
- git_contribution_analyzer/application/use_cases/assess_work_series.py +212 -0
- git_contribution_analyzer/application/use_cases/compare_assessment_runs.py +121 -0
- git_contribution_analyzer/application/use_cases/export_report.py +49 -0
- git_contribution_analyzer/application/use_cases/generate_brag.py +308 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_recap.py +244 -0
- git_contribution_analyzer/application/use_cases/generate_portfolio_resume.py +152 -0
- git_contribution_analyzer/application/use_cases/generate_recap.py +316 -0
- git_contribution_analyzer/application/use_cases/generate_report.py +32 -0
- git_contribution_analyzer/application/use_cases/generate_resume.py +209 -0
- git_contribution_analyzer/application/use_cases/get_portfolio_status.py +83 -0
- git_contribution_analyzer/application/use_cases/get_run.py +16 -0
- git_contribution_analyzer/application/use_cases/get_status.py +69 -0
- git_contribution_analyzer/application/use_cases/index_repository.py +267 -0
- git_contribution_analyzer/application/use_cases/init_portfolio.py +89 -0
- git_contribution_analyzer/application/use_cases/init_project.py +71 -0
- git_contribution_analyzer/application/use_cases/list_identities.py +16 -0
- git_contribution_analyzer/application/use_cases/list_providers.py +29 -0
- git_contribution_analyzer/application/use_cases/list_runs.py +17 -0
- git_contribution_analyzer/application/use_cases/manage_identity_merges.py +48 -0
- git_contribution_analyzer/application/use_cases/manage_outcomes.py +189 -0
- git_contribution_analyzer/application/use_cases/manage_structural_baselines.py +262 -0
- git_contribution_analyzer/application/use_cases/map_identity.py +28 -0
- git_contribution_analyzer/application/use_cases/recover_runs.py +22 -0
- git_contribution_analyzer/application/use_cases/run_doctor.py +81 -0
- git_contribution_analyzer/application/use_cases/sync_portfolio.py +232 -0
- git_contribution_analyzer/application/use_cases/test_provider.py +22 -0
- git_contribution_analyzer/application/use_cases/uninit_project.py +23 -0
- git_contribution_analyzer/application/use_cases/verify_portfolio.py +165 -0
- git_contribution_analyzer/cli/__init__.py +1 -0
- git_contribution_analyzer/cli/app.py +1430 -0
- git_contribution_analyzer/cli/exit_codes.py +13 -0
- git_contribution_analyzer/cli/output.py +26 -0
- git_contribution_analyzer/cli/portfolio_commands.py +629 -0
- git_contribution_analyzer/domain/__init__.py +1 -0
- git_contribution_analyzer/domain/errors.py +55 -0
- git_contribution_analyzer/domain/models/__init__.py +3 -0
- git_contribution_analyzer/domain/models/analysis.py +29 -0
- git_contribution_analyzer/domain/models/assessment.py +12 -0
- git_contribution_analyzer/domain/models/brag.py +148 -0
- git_contribution_analyzer/domain/models/contribution.py +55 -0
- git_contribution_analyzer/domain/models/git_history.py +69 -0
- git_contribution_analyzer/domain/models/person_selection.py +46 -0
- git_contribution_analyzer/domain/models/portfolio.py +498 -0
- git_contribution_analyzer/domain/models/ranking.py +48 -0
- git_contribution_analyzer/domain/models/recap.py +235 -0
- git_contribution_analyzer/domain/models/repository.py +10 -0
- git_contribution_analyzer/domain/models/resume.py +59 -0
- git_contribution_analyzer/domain/models/run.py +10 -0
- git_contribution_analyzer/domain/models/semantic.py +34 -0
- git_contribution_analyzer/domain/models/snapshot.py +208 -0
- git_contribution_analyzer/domain/models/structural_baseline.py +120 -0
- git_contribution_analyzer/domain/models/work_assessment.py +81 -0
- git_contribution_analyzer/domain/services/assessment_periods.py +182 -0
- git_contribution_analyzer/domain/services/brag_rules.py +250 -0
- git_contribution_analyzer/domain/services/capability_rules.py +91 -0
- git_contribution_analyzer/domain/services/contribution_clustering.py +98 -0
- git_contribution_analyzer/domain/services/contribution_rules.py +79 -0
- git_contribution_analyzer/domain/services/difficulty_rules.py +191 -0
- git_contribution_analyzer/domain/services/dimensional_summary.py +117 -0
- git_contribution_analyzer/domain/services/portfolio_aggregation.py +250 -0
- git_contribution_analyzer/domain/services/portfolio_resume_rules.py +265 -0
- git_contribution_analyzer/domain/services/portfolio_verifier.py +238 -0
- git_contribution_analyzer/domain/services/ranking_rules.py +226 -0
- git_contribution_analyzer/domain/services/recap_rules.py +268 -0
- git_contribution_analyzer/domain/services/resume_claim_rules.py +70 -0
- git_contribution_analyzer/domain/services/structural_baseline.py +317 -0
- git_contribution_analyzer/domain/services/structural_signals.py +151 -0
- git_contribution_analyzer/domain/services/workload_rules.py +185 -0
- git_contribution_analyzer/gui/__init__.py +1 -0
- git_contribution_analyzer/gui/qml/Main.qml +1141 -0
- git_contribution_analyzer/gui/qml/__init__.py +1 -0
- git_contribution_analyzer/prompts/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/assessment/v1/explanation.txt +4 -0
- git_contribution_analyzer/prompts/resume/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-concise.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-star.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/style-xyz.txt +1 -0
- git_contribution_analyzer/prompts/resume/v1/system.txt +3 -0
- git_contribution_analyzer/prompts/v1/__init__.py +1 -0
- git_contribution_analyzer/prompts/v1/capability_explanation.txt +2 -0
- git_contribution_analyzer/prompts/v1/contribution_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/overall_summary.txt +2 -0
- git_contribution_analyzer/prompts/v1/resume_bullet.txt +2 -0
- git_contribution_analyzer-0.8.0.dist-info/METADATA +667 -0
- git_contribution_analyzer-0.8.0.dist-info/RECORD +187 -0
- git_contribution_analyzer-0.8.0.dist-info/WHEEL +4 -0
- git_contribution_analyzer-0.8.0.dist-info/entry_points.txt +3 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/LICENSE +201 -0
- git_contribution_analyzer-0.8.0.dist-info/licenses/NOTICE +6 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import replace
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
from uuid import uuid4
|
|
8
|
+
|
|
9
|
+
from git_contribution_analyzer.adapters.git.native_git import NativeGitHistory
|
|
10
|
+
from git_contribution_analyzer.adapters.git.repository_discovery import discover_repository
|
|
11
|
+
from git_contribution_analyzer.adapters.storage.sqlite.analysis import SqliteAnalysisStore
|
|
12
|
+
from git_contribution_analyzer.adapters.storage.sqlite.database import initialize_database
|
|
13
|
+
from git_contribution_analyzer.adapters.workspace.config import load_config
|
|
14
|
+
from git_contribution_analyzer.adapters.workspace.layout import WorkspaceLayout
|
|
15
|
+
from git_contribution_analyzer.application.ports.cancellation import (
|
|
16
|
+
CancellationToken,
|
|
17
|
+
NeverCancelledToken,
|
|
18
|
+
)
|
|
19
|
+
from git_contribution_analyzer.application.ports.llm import LlmProvider
|
|
20
|
+
from git_contribution_analyzer.application.ports.progress import (
|
|
21
|
+
NullProgressReporter,
|
|
22
|
+
ProgressEvent,
|
|
23
|
+
ProgressReporter,
|
|
24
|
+
)
|
|
25
|
+
from git_contribution_analyzer.application.use_cases.assess_work import (
|
|
26
|
+
assess_work,
|
|
27
|
+
build_assessment_workload_baseline,
|
|
28
|
+
)
|
|
29
|
+
from git_contribution_analyzer.domain.models.analysis import AnalysisFilters
|
|
30
|
+
from git_contribution_analyzer.domain.models.ranking import RankingConfig
|
|
31
|
+
from git_contribution_analyzer.domain.models.run import RunType
|
|
32
|
+
from git_contribution_analyzer.domain.services.assessment_periods import (
|
|
33
|
+
build_period_comparison,
|
|
34
|
+
split_periods,
|
|
35
|
+
summarize_assessment,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def assess_work_series(
|
|
40
|
+
path: Path,
|
|
41
|
+
*,
|
|
42
|
+
period: str,
|
|
43
|
+
person_selectors: tuple[str, ...] = (),
|
|
44
|
+
all_people: bool = False,
|
|
45
|
+
exclude_selectors: tuple[str, ...] = (),
|
|
46
|
+
rank_by: tuple[str, ...] = (),
|
|
47
|
+
ranking_config: RankingConfig | None = None,
|
|
48
|
+
filters: AnalysisFilters,
|
|
49
|
+
llm_provider: LlmProvider | None = None,
|
|
50
|
+
allow_llm_fallback: bool = True,
|
|
51
|
+
progress: ProgressReporter | None = None,
|
|
52
|
+
cancellation: CancellationToken | None = None,
|
|
53
|
+
) -> dict[str, Any]:
|
|
54
|
+
active_progress = progress or NullProgressReporter()
|
|
55
|
+
active_cancellation = cancellation or NeverCancelledToken()
|
|
56
|
+
active_cancellation.raise_if_cancelled()
|
|
57
|
+
if filters.since is None or filters.until is None:
|
|
58
|
+
raise ValueError("Periodic assessment requires both since and until")
|
|
59
|
+
windows = split_periods(
|
|
60
|
+
filters.since,
|
|
61
|
+
filters.until,
|
|
62
|
+
period,
|
|
63
|
+
use_system_timezone=filters.system_timezone,
|
|
64
|
+
)
|
|
65
|
+
repository = discover_repository(path)
|
|
66
|
+
layout = WorkspaceLayout.for_repository(repository.root)
|
|
67
|
+
config = load_config(layout.config)
|
|
68
|
+
history = NativeGitHistory(repository.root)
|
|
69
|
+
integration_times = (
|
|
70
|
+
history.integration_times(f"refs/heads/{config.default_branch}")
|
|
71
|
+
if filters.time_basis in {"MERGED", "LANDED"}
|
|
72
|
+
else {}
|
|
73
|
+
)
|
|
74
|
+
release_times = history.release_times() if filters.time_basis == "RELEASED" else {}
|
|
75
|
+
workload_baseline = build_assessment_workload_baseline(
|
|
76
|
+
path,
|
|
77
|
+
person_selectors=person_selectors,
|
|
78
|
+
all_people=all_people,
|
|
79
|
+
exclude_selectors=exclude_selectors,
|
|
80
|
+
filters=filters,
|
|
81
|
+
integration_times=integration_times,
|
|
82
|
+
release_times=release_times,
|
|
83
|
+
)
|
|
84
|
+
series_task_id = str(uuid4())
|
|
85
|
+
child_reports = []
|
|
86
|
+
for index, window in enumerate(windows, start=1):
|
|
87
|
+
active_cancellation.raise_if_cancelled()
|
|
88
|
+
active_progress.report(
|
|
89
|
+
ProgressEvent(
|
|
90
|
+
task_id=series_task_id,
|
|
91
|
+
operation="assess_series",
|
|
92
|
+
stage="evaluating_period",
|
|
93
|
+
repository=repository.root,
|
|
94
|
+
current=index - 1,
|
|
95
|
+
total=len(windows),
|
|
96
|
+
message=f"Evaluating {window.label}",
|
|
97
|
+
occurred_at=datetime.now(UTC),
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
child_reports.append(
|
|
101
|
+
assess_work(
|
|
102
|
+
path,
|
|
103
|
+
person_selectors=person_selectors,
|
|
104
|
+
all_people=all_people,
|
|
105
|
+
exclude_selectors=exclude_selectors,
|
|
106
|
+
rank_by=rank_by,
|
|
107
|
+
ranking_config=ranking_config,
|
|
108
|
+
filters=replace(filters, since=window.since, until=window.until),
|
|
109
|
+
llm_provider=llm_provider,
|
|
110
|
+
allow_llm_fallback=allow_llm_fallback,
|
|
111
|
+
workload_baseline=workload_baseline,
|
|
112
|
+
integration_times=integration_times,
|
|
113
|
+
release_times=release_times,
|
|
114
|
+
progress=active_progress,
|
|
115
|
+
cancellation=active_cancellation,
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
initialize_database(layout.database)
|
|
120
|
+
store = SqliteAnalysisStore(layout.database, str(repository.root))
|
|
121
|
+
started_at = datetime.now(UTC)
|
|
122
|
+
run_id = series_task_id
|
|
123
|
+
summaries = [summarize_assessment(report) for report in child_reports]
|
|
124
|
+
by_comparison_key: dict[tuple[int, int], dict[str, int]] = {}
|
|
125
|
+
serialized_periods = []
|
|
126
|
+
for index, (window, report, summary) in enumerate(
|
|
127
|
+
zip(windows, child_reports, summaries, strict=True)
|
|
128
|
+
):
|
|
129
|
+
previous = summaries[index - 1] if index else None
|
|
130
|
+
previous_year = by_comparison_key.get(
|
|
131
|
+
(window.comparison_key[0] - 1, window.comparison_key[1])
|
|
132
|
+
)
|
|
133
|
+
serialized_periods.append(
|
|
134
|
+
{
|
|
135
|
+
"label": window.label,
|
|
136
|
+
"since": window.since.isoformat(),
|
|
137
|
+
"until": window.until.isoformat(),
|
|
138
|
+
"partial": window.partial,
|
|
139
|
+
"runId": report["run"]["id"],
|
|
140
|
+
"status": report["run"]["status"],
|
|
141
|
+
"metrics": summary,
|
|
142
|
+
"comparison": build_period_comparison(summary, previous, previous_year),
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
by_comparison_key[window.comparison_key] = summary
|
|
146
|
+
|
|
147
|
+
warnings = [
|
|
148
|
+
"Partial boundary periods should not be compared directly with complete periods."
|
|
149
|
+
for window in windows
|
|
150
|
+
if window.partial
|
|
151
|
+
][:1]
|
|
152
|
+
report = {
|
|
153
|
+
"schemaVersion": "1.0",
|
|
154
|
+
"reportType": "WORK_ASSESSMENT_SERIES",
|
|
155
|
+
"run": {
|
|
156
|
+
"id": run_id,
|
|
157
|
+
"runType": RunType.WORK_ASSESSMENT_SERIES.value,
|
|
158
|
+
"status": "COMPLETED",
|
|
159
|
+
"startedAt": started_at.isoformat(),
|
|
160
|
+
"completedAt": started_at.isoformat(),
|
|
161
|
+
"ruleVersion": "work-assessment-series-v1",
|
|
162
|
+
},
|
|
163
|
+
"period": period.casefold(),
|
|
164
|
+
"timeBasis": filters.time_basis,
|
|
165
|
+
"inputTimeZone": "SYSTEM" if filters.system_timezone else "EXPLICIT",
|
|
166
|
+
"range": {
|
|
167
|
+
"since": filters.since.isoformat(),
|
|
168
|
+
"until": filters.until.isoformat(),
|
|
169
|
+
},
|
|
170
|
+
"periods": serialized_periods,
|
|
171
|
+
"warnings": warnings,
|
|
172
|
+
"limitations": [
|
|
173
|
+
"Period comparisons are valid only for the same repository, cohort, filters, "
|
|
174
|
+
"and rule versions.",
|
|
175
|
+
"Git evidence does not measure hours worked or employee value.",
|
|
176
|
+
],
|
|
177
|
+
}
|
|
178
|
+
store.start_run(
|
|
179
|
+
run_id=run_id,
|
|
180
|
+
person_id=None,
|
|
181
|
+
parameters={
|
|
182
|
+
"period": period.casefold(),
|
|
183
|
+
"timeBasis": filters.time_basis,
|
|
184
|
+
"filters": filters.as_dict(),
|
|
185
|
+
"childRunIds": [entry["runId"] for entry in serialized_periods],
|
|
186
|
+
},
|
|
187
|
+
baseline_commit=store.baseline_commit(),
|
|
188
|
+
started_at=started_at,
|
|
189
|
+
run_type=RunType.WORK_ASSESSMENT_SERIES,
|
|
190
|
+
)
|
|
191
|
+
active_cancellation.raise_if_cancelled()
|
|
192
|
+
completed_at = datetime.now(UTC)
|
|
193
|
+
report["run"]["completedAt"] = completed_at.isoformat()
|
|
194
|
+
store.complete_run(
|
|
195
|
+
run_id=run_id,
|
|
196
|
+
completed_at=completed_at,
|
|
197
|
+
report=report,
|
|
198
|
+
persist_details=False,
|
|
199
|
+
)
|
|
200
|
+
active_progress.report(
|
|
201
|
+
ProgressEvent(
|
|
202
|
+
task_id=run_id,
|
|
203
|
+
operation="assess_series",
|
|
204
|
+
stage="completed",
|
|
205
|
+
repository=repository.root,
|
|
206
|
+
current=len(windows),
|
|
207
|
+
total=len(windows),
|
|
208
|
+
message="Assessment series completed",
|
|
209
|
+
occurred_at=completed_at,
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
return report
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from git_contribution_analyzer.application.use_cases.get_run import get_run
|
|
7
|
+
from git_contribution_analyzer.domain.errors import ReportError
|
|
8
|
+
from git_contribution_analyzer.domain.services.assessment_periods import (
|
|
9
|
+
DIFFICULTY_POINTS,
|
|
10
|
+
SIZE_POINTS,
|
|
11
|
+
build_period_comparison,
|
|
12
|
+
summarize_assessment,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def compare_assessment_runs(path: Path, base_run_id: str, target_run_id: str) -> dict[str, Any]:
|
|
17
|
+
base = get_run(path, base_run_id)
|
|
18
|
+
target = get_run(path, target_run_id)
|
|
19
|
+
for run_id, report in ((base_run_id, base), (target_run_id, target)):
|
|
20
|
+
if report.get("reportType") != "WORK_ASSESSMENT":
|
|
21
|
+
raise ReportError(f"Run is not a work assessment: {run_id}")
|
|
22
|
+
|
|
23
|
+
base_summary = summarize_assessment(base)
|
|
24
|
+
target_summary = summarize_assessment(target)
|
|
25
|
+
changes = build_period_comparison(target_summary, base_summary, None)["periodOverPeriod"]
|
|
26
|
+
warnings = _comparability_warnings(base, target)
|
|
27
|
+
return {
|
|
28
|
+
"schemaVersion": "1.0",
|
|
29
|
+
"reportType": "WORK_ASSESSMENT_COMPARISON",
|
|
30
|
+
"baseRunId": str(base["run"]["id"]),
|
|
31
|
+
"targetRunId": str(target["run"]["id"]),
|
|
32
|
+
"baseSnapshotId": base["snapshot"].get("id"),
|
|
33
|
+
"targetSnapshotId": target["snapshot"].get("id"),
|
|
34
|
+
"changes": changes,
|
|
35
|
+
"sizeDistributionChanges": _distribution_changes(
|
|
36
|
+
base["workloadSummary"]["sizeDistribution"],
|
|
37
|
+
target["workloadSummary"]["sizeDistribution"],
|
|
38
|
+
),
|
|
39
|
+
"difficultyDistributionChanges": _distribution_changes(
|
|
40
|
+
base["difficultyDistribution"], target["difficultyDistribution"]
|
|
41
|
+
),
|
|
42
|
+
"subjects": _subject_changes(base, target),
|
|
43
|
+
"warnings": warnings,
|
|
44
|
+
"comparable": not warnings,
|
|
45
|
+
"limitations": [
|
|
46
|
+
"Deltas compare Git evidence under the stored rules; they do not measure hours "
|
|
47
|
+
"or employee value."
|
|
48
|
+
],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _distribution_changes(base: dict[str, int], target: dict[str, int]) -> dict[str, int]:
|
|
53
|
+
return {
|
|
54
|
+
key: int(target.get(key, 0)) - int(base.get(key, 0))
|
|
55
|
+
for key in sorted(set(base) | set(target))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _subject_changes(base: dict[str, Any], target: dict[str, Any]) -> list[dict[str, Any]]:
|
|
60
|
+
base_subjects = {entry["person"]["id"]: entry for entry in base["subjects"]}
|
|
61
|
+
target_subjects = {entry["person"]["id"]: entry for entry in target["subjects"]}
|
|
62
|
+
result = []
|
|
63
|
+
for person_id in sorted(set(base_subjects) | set(target_subjects)):
|
|
64
|
+
base_subject = base_subjects.get(person_id)
|
|
65
|
+
target_subject = target_subjects.get(person_id)
|
|
66
|
+
base_metrics = _subject_metrics(base_subject)
|
|
67
|
+
target_metrics = _subject_metrics(target_subject)
|
|
68
|
+
selected_subject = target_subject or base_subject
|
|
69
|
+
if selected_subject is None:
|
|
70
|
+
continue
|
|
71
|
+
person = selected_subject["person"]
|
|
72
|
+
result.append(
|
|
73
|
+
{
|
|
74
|
+
"person": {"id": person["id"], "name": person["name"]},
|
|
75
|
+
"base": base_metrics,
|
|
76
|
+
"target": target_metrics,
|
|
77
|
+
"changes": build_period_comparison(
|
|
78
|
+
target_metrics, base_metrics, None
|
|
79
|
+
)["periodOverPeriod"],
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
return result
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _subject_metrics(subject: dict[str, Any] | None) -> dict[str, int]:
|
|
86
|
+
if subject is None:
|
|
87
|
+
return {
|
|
88
|
+
"completedItems": 0,
|
|
89
|
+
"pendingItems": 0,
|
|
90
|
+
"reworkItems": 0,
|
|
91
|
+
"integrationItems": 0,
|
|
92
|
+
"workloadPoints": 0,
|
|
93
|
+
"difficultyPoints": 0,
|
|
94
|
+
}
|
|
95
|
+
items = subject["itemAssessments"]
|
|
96
|
+
completed = [item for item in items if item["completionBucket"] == "COMPLETED"]
|
|
97
|
+
return {
|
|
98
|
+
"completedItems": len(completed),
|
|
99
|
+
"pendingItems": sum(item["completionBucket"] == "PENDING" for item in items),
|
|
100
|
+
"reworkItems": sum(item["completionBucket"] == "REWORK" for item in items),
|
|
101
|
+
"integrationItems": len(subject["integrationWork"]),
|
|
102
|
+
"workloadPoints": sum(SIZE_POINTS[item["size"]["band"]] for item in completed),
|
|
103
|
+
"difficultyPoints": sum(
|
|
104
|
+
DIFFICULTY_POINTS[item["difficulty"]["level"]] for item in completed
|
|
105
|
+
),
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def _comparability_warnings(base: dict[str, Any], target: dict[str, Any]) -> list[str]:
|
|
110
|
+
warnings = []
|
|
111
|
+
if base["run"].get("ruleVersion") != target["run"].get("ruleVersion"):
|
|
112
|
+
warnings.append("Rule versions differ; metric deltas may not be directly comparable.")
|
|
113
|
+
if base["snapshot"]["filters"].get("timeBasis", "AUTHORED") != target["snapshot"][
|
|
114
|
+
"filters"
|
|
115
|
+
].get("timeBasis", "AUTHORED"):
|
|
116
|
+
warnings.append("Assessment time bases differ.")
|
|
117
|
+
if set(base["selection"]["includedPersonIds"]) != set(
|
|
118
|
+
target["selection"]["includedPersonIds"]
|
|
119
|
+
):
|
|
120
|
+
warnings.append("Assessment cohorts differ.")
|
|
121
|
+
return warnings
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import tempfile
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from git_contribution_analyzer.application.use_cases.generate_report import generate_report
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def export_report(
|
|
11
|
+
path: Path,
|
|
12
|
+
run_id: str,
|
|
13
|
+
report_format: str,
|
|
14
|
+
target: Path,
|
|
15
|
+
*,
|
|
16
|
+
include_email: bool = False,
|
|
17
|
+
overwrite: bool = False,
|
|
18
|
+
) -> Path:
|
|
19
|
+
resolved = target.expanduser().resolve()
|
|
20
|
+
if resolved.exists() and not overwrite:
|
|
21
|
+
raise FileExistsError(f"Report already exists: {resolved}")
|
|
22
|
+
rendered = generate_report(
|
|
23
|
+
path,
|
|
24
|
+
run_id,
|
|
25
|
+
report_format,
|
|
26
|
+
include_email=include_email,
|
|
27
|
+
)
|
|
28
|
+
resolved.parent.mkdir(parents=True, exist_ok=True)
|
|
29
|
+
temporary_path: Path | None = None
|
|
30
|
+
try:
|
|
31
|
+
with tempfile.NamedTemporaryFile(
|
|
32
|
+
mode="w",
|
|
33
|
+
encoding="utf-8",
|
|
34
|
+
newline="",
|
|
35
|
+
dir=resolved.parent,
|
|
36
|
+
prefix=f".{resolved.name}.",
|
|
37
|
+
suffix=".tmp",
|
|
38
|
+
delete=False,
|
|
39
|
+
) as temporary:
|
|
40
|
+
temporary.write(rendered)
|
|
41
|
+
temporary.flush()
|
|
42
|
+
os.fsync(temporary.fileno())
|
|
43
|
+
temporary_path = Path(temporary.name)
|
|
44
|
+
os.replace(temporary_path, resolved)
|
|
45
|
+
temporary_path = None
|
|
46
|
+
finally:
|
|
47
|
+
if temporary_path is not None:
|
|
48
|
+
temporary_path.unlink(missing_ok=True)
|
|
49
|
+
return resolved
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from datetime import datetime
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
from uuid import uuid4
|
|
8
|
+
|
|
9
|
+
from git_contribution_analyzer.adapters.git.repository_discovery import discover_repository
|
|
10
|
+
from git_contribution_analyzer.adapters.outcomes.yaml_store import (
|
|
11
|
+
default_outcomes_path,
|
|
12
|
+
load_outcomes_if_exists,
|
|
13
|
+
)
|
|
14
|
+
from git_contribution_analyzer.adapters.workspace.layout import WorkspaceLayout
|
|
15
|
+
from git_contribution_analyzer.adapters.workspace.portfolio_workspace import FilePortfolioStore
|
|
16
|
+
from git_contribution_analyzer.application.ports.cancellation import (
|
|
17
|
+
CancellationToken,
|
|
18
|
+
NeverCancelledToken,
|
|
19
|
+
)
|
|
20
|
+
from git_contribution_analyzer.application.ports.progress import (
|
|
21
|
+
NullProgressReporter,
|
|
22
|
+
ProgressReporter,
|
|
23
|
+
)
|
|
24
|
+
from git_contribution_analyzer.application.services.default_person import (
|
|
25
|
+
resolve_portfolio_default_person,
|
|
26
|
+
resolve_repo_default_person,
|
|
27
|
+
)
|
|
28
|
+
from git_contribution_analyzer.application.use_cases.analyze_contributions import (
|
|
29
|
+
analyze_contributions,
|
|
30
|
+
)
|
|
31
|
+
from git_contribution_analyzer.application.use_cases.assess_portfolio import (
|
|
32
|
+
resolve_portfolio_identity,
|
|
33
|
+
)
|
|
34
|
+
from git_contribution_analyzer.application.use_cases.assess_work import assess_work
|
|
35
|
+
from git_contribution_analyzer.application.use_cases.generate_recap import (
|
|
36
|
+
_confirm_exact_email_identity_if_needed,
|
|
37
|
+
extract_repo_recap_slice,
|
|
38
|
+
)
|
|
39
|
+
from git_contribution_analyzer.application.use_cases.index_repository import index_repository
|
|
40
|
+
from git_contribution_analyzer.application.use_cases.init_project import init_project
|
|
41
|
+
from git_contribution_analyzer.application.use_cases.sync_portfolio import sync_portfolio
|
|
42
|
+
from git_contribution_analyzer.domain.errors import GcaError, IdentityResolutionError
|
|
43
|
+
from git_contribution_analyzer.domain.models.analysis import AnalysisFilters
|
|
44
|
+
from git_contribution_analyzer.domain.models.brag import BragDeliveredItem, BragScope
|
|
45
|
+
from git_contribution_analyzer.domain.models.resume import VerifiedOutcome
|
|
46
|
+
from git_contribution_analyzer.domain.services.brag_rules import (
|
|
47
|
+
build_brag_document,
|
|
48
|
+
resolve_brag_period,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
IdGenerator = Callable[[], str]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _load_target_outcomes(
|
|
55
|
+
target_dir: Path,
|
|
56
|
+
outcomes_file: Path | None,
|
|
57
|
+
) -> tuple[VerifiedOutcome, ...]:
|
|
58
|
+
path = (
|
|
59
|
+
outcomes_file.expanduser().resolve()
|
|
60
|
+
if outcomes_file is not None
|
|
61
|
+
else default_outcomes_path(target_dir)
|
|
62
|
+
)
|
|
63
|
+
return load_outcomes_if_exists(path)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def generate_brag(
|
|
67
|
+
path: Path,
|
|
68
|
+
*,
|
|
69
|
+
person_selector: str | None = None,
|
|
70
|
+
year: int | None = None,
|
|
71
|
+
quarter: str | None = None,
|
|
72
|
+
since: datetime | None = None,
|
|
73
|
+
until: datetime | None = None,
|
|
74
|
+
branch: str | None = None,
|
|
75
|
+
outcomes_file: Path | None = None,
|
|
76
|
+
auto_sync: bool = False,
|
|
77
|
+
reference_now: datetime | None = None,
|
|
78
|
+
progress: ProgressReporter | None = None,
|
|
79
|
+
cancellation: CancellationToken | None = None,
|
|
80
|
+
) -> dict[str, Any]:
|
|
81
|
+
"""生成单仓库年度/季度 Brag Document(自动关联本地 outcomes.yml)."""
|
|
82
|
+
active_cancellation = cancellation or NeverCancelledToken()
|
|
83
|
+
active_progress = progress or NullProgressReporter()
|
|
84
|
+
active_cancellation.raise_if_cancelled()
|
|
85
|
+
|
|
86
|
+
period = resolve_brag_period(
|
|
87
|
+
year=year,
|
|
88
|
+
quarter=quarter,
|
|
89
|
+
since=since,
|
|
90
|
+
until=until,
|
|
91
|
+
reference_now=reference_now,
|
|
92
|
+
)
|
|
93
|
+
repository = discover_repository(path)
|
|
94
|
+
repo_key = repository.root.name
|
|
95
|
+
|
|
96
|
+
if auto_sync:
|
|
97
|
+
layout = WorkspaceLayout.for_repository(repository.root)
|
|
98
|
+
if not layout.database.is_file():
|
|
99
|
+
init_project(
|
|
100
|
+
repository.root,
|
|
101
|
+
progress=active_progress,
|
|
102
|
+
cancellation=active_cancellation,
|
|
103
|
+
)
|
|
104
|
+
else:
|
|
105
|
+
index_repository(
|
|
106
|
+
repository.root,
|
|
107
|
+
full_rebuild=False,
|
|
108
|
+
progress=active_progress,
|
|
109
|
+
cancellation=active_cancellation,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
resolved_selector = (
|
|
113
|
+
person_selector.strip()
|
|
114
|
+
if person_selector and person_selector.strip()
|
|
115
|
+
else resolve_repo_default_person(repository.root)
|
|
116
|
+
)
|
|
117
|
+
if auto_sync:
|
|
118
|
+
_confirm_exact_email_identity_if_needed(repository.root, resolved_selector)
|
|
119
|
+
|
|
120
|
+
filters = AnalysisFilters(since=period.since, until=period.until, branch=branch)
|
|
121
|
+
analysis = analyze_contributions(
|
|
122
|
+
repository.root,
|
|
123
|
+
person_selector=resolved_selector,
|
|
124
|
+
filters=filters,
|
|
125
|
+
llm_provider=None,
|
|
126
|
+
)
|
|
127
|
+
assessment = assess_work(
|
|
128
|
+
repository.root,
|
|
129
|
+
person_selectors=(resolved_selector,),
|
|
130
|
+
filters=filters,
|
|
131
|
+
llm_provider=None,
|
|
132
|
+
progress=active_progress,
|
|
133
|
+
cancellation=active_cancellation,
|
|
134
|
+
)
|
|
135
|
+
repo_slice = extract_repo_recap_slice(
|
|
136
|
+
repo_key=repo_key,
|
|
137
|
+
group="repository",
|
|
138
|
+
analysis=analysis,
|
|
139
|
+
assessment=assessment,
|
|
140
|
+
)
|
|
141
|
+
delivered_items = tuple(
|
|
142
|
+
BragDeliveredItem(
|
|
143
|
+
repo_key=item.repo_key,
|
|
144
|
+
group=item.group,
|
|
145
|
+
item_id=item.item_id,
|
|
146
|
+
title=item.title,
|
|
147
|
+
commits=item.commits,
|
|
148
|
+
evidence_ids=item.evidence_ids,
|
|
149
|
+
difficulty=item.difficulty,
|
|
150
|
+
size=item.size,
|
|
151
|
+
)
|
|
152
|
+
for item in repo_slice.items
|
|
153
|
+
if not item.pending
|
|
154
|
+
)
|
|
155
|
+
outcomes = _load_target_outcomes(repository.root, outcomes_file)
|
|
156
|
+
|
|
157
|
+
report = build_brag_document(
|
|
158
|
+
report_type="BRAG_DOCUMENT",
|
|
159
|
+
period=period,
|
|
160
|
+
scope=BragScope(
|
|
161
|
+
mode="REPOSITORY",
|
|
162
|
+
name=repo_key,
|
|
163
|
+
repositories=1,
|
|
164
|
+
matched_repositories=1 if repo_slice.commits > 0 else 0,
|
|
165
|
+
),
|
|
166
|
+
person_name=repo_slice.person_name,
|
|
167
|
+
commits=repo_slice.commits,
|
|
168
|
+
delivered_commits=repo_slice.delivered_commits,
|
|
169
|
+
delivered_items=delivered_items,
|
|
170
|
+
outcomes=outcomes,
|
|
171
|
+
warnings=repo_slice.warnings,
|
|
172
|
+
)
|
|
173
|
+
return {"report": report.to_schema_dict()}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def generate_portfolio_brag(
|
|
177
|
+
portfolio_dir: Path,
|
|
178
|
+
*,
|
|
179
|
+
person_selector: str | None = None,
|
|
180
|
+
year: int | None = None,
|
|
181
|
+
quarter: str | None = None,
|
|
182
|
+
since: datetime | None = None,
|
|
183
|
+
until: datetime | None = None,
|
|
184
|
+
outcomes_file: Path | None = None,
|
|
185
|
+
refresh: bool = False,
|
|
186
|
+
continue_on_error: bool = True,
|
|
187
|
+
reference_now: datetime | None = None,
|
|
188
|
+
id_generator: IdGenerator | None = None,
|
|
189
|
+
progress: ProgressReporter | None = None,
|
|
190
|
+
cancellation: CancellationToken | None = None,
|
|
191
|
+
) -> dict[str, Any]:
|
|
192
|
+
"""生成多仓年度/季度 Brag Document 并持久化至 `.gca-portfolio/runs/`."""
|
|
193
|
+
active_cancellation = cancellation or NeverCancelledToken()
|
|
194
|
+
active_progress = progress or NullProgressReporter()
|
|
195
|
+
next_id = id_generator or (lambda: str(uuid4()))
|
|
196
|
+
|
|
197
|
+
period = resolve_brag_period(
|
|
198
|
+
year=year,
|
|
199
|
+
quarter=quarter,
|
|
200
|
+
since=since,
|
|
201
|
+
until=until,
|
|
202
|
+
reference_now=reference_now,
|
|
203
|
+
)
|
|
204
|
+
store = FilePortfolioStore(portfolio_dir)
|
|
205
|
+
manifest = store.load_manifest()
|
|
206
|
+
resolved_selector = (
|
|
207
|
+
person_selector.strip()
|
|
208
|
+
if person_selector and person_selector.strip()
|
|
209
|
+
else resolve_portfolio_default_person(portfolio_dir)
|
|
210
|
+
)
|
|
211
|
+
identity = resolve_portfolio_identity(resolved_selector, manifest.identities)
|
|
212
|
+
|
|
213
|
+
if refresh:
|
|
214
|
+
sync_portfolio(
|
|
215
|
+
portfolio_dir,
|
|
216
|
+
continue_on_error=continue_on_error,
|
|
217
|
+
progress=active_progress,
|
|
218
|
+
cancellation=active_cancellation,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
filters = AnalysisFilters(since=period.since, until=period.until)
|
|
222
|
+
matched_repos = 0
|
|
223
|
+
total_commits = 0
|
|
224
|
+
delivered_commits = 0
|
|
225
|
+
all_delivered: list[BragDeliveredItem] = []
|
|
226
|
+
failed: list[dict[str, str]] = []
|
|
227
|
+
warnings: list[str] = []
|
|
228
|
+
|
|
229
|
+
for repo in manifest.repositories:
|
|
230
|
+
active_cancellation.raise_if_cancelled()
|
|
231
|
+
repo_path = store.resolve_repo_path(repo)
|
|
232
|
+
try:
|
|
233
|
+
if not repo_path.is_dir():
|
|
234
|
+
raise GcaError(f"Repository path does not exist: {repo.repo_key}")
|
|
235
|
+
try:
|
|
236
|
+
analysis = analyze_contributions(
|
|
237
|
+
repo_path,
|
|
238
|
+
person_selector=identity.canonical_email,
|
|
239
|
+
filters=filters,
|
|
240
|
+
llm_provider=None,
|
|
241
|
+
)
|
|
242
|
+
assessment = assess_work(
|
|
243
|
+
repo_path,
|
|
244
|
+
person_selectors=(identity.canonical_email,),
|
|
245
|
+
filters=filters,
|
|
246
|
+
llm_provider=None,
|
|
247
|
+
)
|
|
248
|
+
except IdentityResolutionError:
|
|
249
|
+
continue
|
|
250
|
+
except GcaError as exc:
|
|
251
|
+
if not continue_on_error:
|
|
252
|
+
raise
|
|
253
|
+
failed.append({"repoKey": repo.repo_key, "error": str(exc)})
|
|
254
|
+
warnings.append(f"Repository {repo.repo_key} skipped due to error: {exc}")
|
|
255
|
+
continue
|
|
256
|
+
|
|
257
|
+
repo_slice = extract_repo_recap_slice(
|
|
258
|
+
repo_key=repo.repo_key,
|
|
259
|
+
group=repo.group,
|
|
260
|
+
analysis=analysis,
|
|
261
|
+
assessment=assessment,
|
|
262
|
+
)
|
|
263
|
+
if repo_slice.commits > 0:
|
|
264
|
+
matched_repos += 1
|
|
265
|
+
total_commits += repo_slice.commits
|
|
266
|
+
delivered_commits += repo_slice.delivered_commits
|
|
267
|
+
for item in repo_slice.items:
|
|
268
|
+
if item.pending:
|
|
269
|
+
continue
|
|
270
|
+
all_delivered.append(
|
|
271
|
+
BragDeliveredItem(
|
|
272
|
+
repo_key=item.repo_key,
|
|
273
|
+
group=item.group,
|
|
274
|
+
item_id=item.item_id,
|
|
275
|
+
title=item.title,
|
|
276
|
+
commits=item.commits,
|
|
277
|
+
evidence_ids=item.evidence_ids,
|
|
278
|
+
difficulty=item.difficulty,
|
|
279
|
+
size=item.size,
|
|
280
|
+
)
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
outcomes = _load_target_outcomes(portfolio_dir, outcomes_file)
|
|
284
|
+
report = build_brag_document(
|
|
285
|
+
report_type="PORTFOLIO_BRAG_DOCUMENT",
|
|
286
|
+
period=period,
|
|
287
|
+
scope=BragScope(
|
|
288
|
+
mode="PORTFOLIO",
|
|
289
|
+
name=manifest.name,
|
|
290
|
+
repositories=max(1, len(manifest.repositories)),
|
|
291
|
+
matched_repositories=matched_repos,
|
|
292
|
+
),
|
|
293
|
+
person_name=identity.canonical_name,
|
|
294
|
+
commits=total_commits,
|
|
295
|
+
delivered_commits=delivered_commits,
|
|
296
|
+
delivered_items=all_delivered,
|
|
297
|
+
outcomes=outcomes,
|
|
298
|
+
warnings=warnings,
|
|
299
|
+
)
|
|
300
|
+
payload = report.to_schema_dict()
|
|
301
|
+
run_id = next_id()
|
|
302
|
+
store.save_run(run_id, "PORTFOLIO_BRAG_DOCUMENT", payload)
|
|
303
|
+
return {
|
|
304
|
+
"runId": run_id,
|
|
305
|
+
"status": "PARTIAL" if failed else "COMPLETED",
|
|
306
|
+
"failed": failed,
|
|
307
|
+
"report": payload,
|
|
308
|
+
}
|