codeplain 0.4.3.dev62__py3-none-any.whl → 0.4.3.dev64__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.
- {codeplain-0.4.3.dev62.dist-info → codeplain-0.4.3.dev64.dist-info}/METADATA +2 -2
- {codeplain-0.4.3.dev62.dist-info → codeplain-0.4.3.dev64.dist-info}/RECORD +7 -7
- git_utils.py +24 -6
- tests/test_git_utils.py +107 -0
- {codeplain-0.4.3.dev62.dist-info → codeplain-0.4.3.dev64.dist-info}/WHEEL +0 -0
- {codeplain-0.4.3.dev62.dist-info → codeplain-0.4.3.dev64.dist-info}/entry_points.txt +0 -0
- {codeplain-0.4.3.dev62.dist-info → codeplain-0.4.3.dev64.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: codeplain
|
|
3
|
-
Version: 0.4.3.
|
|
3
|
+
Version: 0.4.3.dev64
|
|
4
4
|
Summary: Transform plain language specifications into working code
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Classifier: Environment :: Console
|
|
@@ -16,7 +16,7 @@ Requires-Dist: python-liquid2==0.4.0
|
|
|
16
16
|
Requires-Dist: pyyaml==6.0.3
|
|
17
17
|
Requires-Dist: requests==2.34.2
|
|
18
18
|
Requires-Dist: rich==15.0.0
|
|
19
|
-
Requires-Dist: sentry-sdk==2.
|
|
19
|
+
Requires-Dist: sentry-sdk==2.74.0
|
|
20
20
|
Requires-Dist: textual>=7.5.0
|
|
21
21
|
Requires-Dist: tiktoken==0.14.0
|
|
22
22
|
Requires-Dist: transitions==0.9.3
|
|
@@ -6,7 +6,7 @@ diff_utils.py,sha256=AjiQlqo5pRos_8hVXZo5yBurl5BzSrTMGrQv4dCtRCg,1198
|
|
|
6
6
|
event_bus.py,sha256=g5XLwRfjrvTIcB6urjREuCJzZj5TA93hy8lKXLGXuCE,650
|
|
7
7
|
file_utils.py,sha256=d46BFIKM97nPTwkiYFoEfTmxAngEajkSKxJbX3orErY,8885
|
|
8
8
|
git_preflight.py,sha256=vB2A8GyYz_iWr8jOE4POFLBHr3qihmedWuidspGdsrw,1509
|
|
9
|
-
git_utils.py,sha256=
|
|
9
|
+
git_utils.py,sha256=2px1u7WyDnRf_37q-lSUw1_wM5sWBk3bgAh6B2S00ck,17108
|
|
10
10
|
memory_management.py,sha256=CwIOQqF7Xo1sNfvP69zQRK_CpjinQD9dbolhRPl6lTk,2446
|
|
11
11
|
metadata_utils.py,sha256=YO17o7IAma5TT1ZN0pTwrLVr_KxFQ8APv02KqKPpI5k,1641
|
|
12
12
|
module_renderer.py,sha256=OvIgAorSxGwrdTZcKy4hdmNgkdJGh6z6-VzzqrTlRHs,6966
|
|
@@ -95,7 +95,7 @@ tests/test_frid_arguments.py,sha256=zIEU2HGgJU4YOY2DXkjO9MmTlIUk4Iu5dfEU9OwKbak,
|
|
|
95
95
|
tests/test_functionality_position.py,sha256=QQdhIqZhRC8-30xKZPyOye6dm8kSkJnja4PB53iZkeE,3540
|
|
96
96
|
tests/test_functionality_without_scenarios.py,sha256=kFBqu9UQ7JdIJCs6z5Hu0xsv9YskBXhkEKBKcdN0tvI,2832
|
|
97
97
|
tests/test_git_preflight.py,sha256=6aQqInDzpk03pS-6UfkGQWjErrIXTEdHs5oeq3ZYzTw,3186
|
|
98
|
-
tests/test_git_utils.py,sha256=
|
|
98
|
+
tests/test_git_utils.py,sha256=ZbxO4tQr8-w4j9NBgOSqZpCy3JIHhiVvsQiqSS8ZtaM,19528
|
|
99
99
|
tests/test_headless_logging.py,sha256=soNESeotKQaU-SQyxtjpq35l-dLVsauZ_lJ-wk9i2mI,6419
|
|
100
100
|
tests/test_log_file_name_resolution.py,sha256=99g9NgPF-BZ98CvNyqDcltBAx4sLBE8gpQPAAieKiPc,3619
|
|
101
101
|
tests/test_logging_config_path_resolution.py,sha256=avz_ehRd18INwIXvAy1AwVzNNUz0vS8eu1nRe0bra8g,2650
|
|
@@ -133,8 +133,8 @@ tui/spinner.py,sha256=Ro6Gd9Przf-whuHqPRY6HwI0T57yJjyNPbhDbigZKZE,2471
|
|
|
133
133
|
tui/state_handlers.py,sha256=5FkF13mCLYAOgpYnzR932U3tYxSnMkCu5jybMFEBVe4,16264
|
|
134
134
|
tui/styles.css,sha256=kiC7Og_2G1E7owoiZgV95-3_dSeQnsNj3qzaY04xkDg,6727
|
|
135
135
|
tui/widget_helpers.py,sha256=jitm2WHiKj-NVFL-hULxWzckPreRbUTl9OIZLN31-ek,6997
|
|
136
|
-
codeplain-0.4.3.
|
|
137
|
-
codeplain-0.4.3.
|
|
138
|
-
codeplain-0.4.3.
|
|
139
|
-
codeplain-0.4.3.
|
|
140
|
-
codeplain-0.4.3.
|
|
136
|
+
codeplain-0.4.3.dev64.dist-info/METADATA,sha256=CdFQy2h8bdAK0B2Ns7JaG7Gt6-E3jwnwhBKQguJysf0,7260
|
|
137
|
+
codeplain-0.4.3.dev64.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
138
|
+
codeplain-0.4.3.dev64.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
|
|
139
|
+
codeplain-0.4.3.dev64.dist-info/licenses/LICENSE,sha256=pCeKgQ1mXE5OmNUuKOfOZh1T1vqkeCUxghE7N8qgnzc,11345
|
|
140
|
+
codeplain-0.4.3.dev64.dist-info/RECORD,,
|
git_utils.py
CHANGED
|
@@ -285,6 +285,13 @@ def _get_commit(repo: Repo, frid: Optional[str]) -> str:
|
|
|
285
285
|
return initial_commit
|
|
286
286
|
|
|
287
287
|
|
|
288
|
+
def _escape_exact_grep_line(line: str) -> str:
|
|
289
|
+
"""Return a POSIX BRE pattern matching an entire commit-message line literally."""
|
|
290
|
+
for ch in ("\\", ".", "[", "]", "*", "^", "$"):
|
|
291
|
+
line = line.replace(ch, f"\\{ch}")
|
|
292
|
+
return f"^{line}$"
|
|
293
|
+
|
|
294
|
+
|
|
288
295
|
def _get_commit_with_frid(repo: Repo, frid: str, module_name: Optional[str] = None) -> str:
|
|
289
296
|
"""
|
|
290
297
|
Finds commit with given frid mentioned in the commit message.
|
|
@@ -305,9 +312,9 @@ def _get_commit_with_frid(repo: Repo, frid: str, module_name: Optional[str] = No
|
|
|
305
312
|
return _get_commit_with_message(repo, commit_message_pattern)
|
|
306
313
|
|
|
307
314
|
# Use multiple grep patterns with --all-match for AND condition
|
|
308
|
-
escaped_frid_message = commit_message_pattern
|
|
315
|
+
escaped_frid_message = _escape_exact_grep_line(commit_message_pattern)
|
|
309
316
|
module_name_pattern = MODULE_NAME_MESSAGE.format(module_name)
|
|
310
|
-
escaped_module_message = module_name_pattern
|
|
317
|
+
escaped_module_message = _escape_exact_grep_line(module_name_pattern)
|
|
311
318
|
|
|
312
319
|
return repo.git.rev_list(
|
|
313
320
|
repo.active_branch.name,
|
|
@@ -337,7 +344,7 @@ def _get_initial_commit(repo: Repo) -> str:
|
|
|
337
344
|
|
|
338
345
|
def _get_commit_with_message(repo: Repo, message: str) -> str:
|
|
339
346
|
"""Finds commit with given message."""
|
|
340
|
-
escaped_message = message
|
|
347
|
+
escaped_message = _escape_exact_grep_line(message)
|
|
341
348
|
|
|
342
349
|
return repo.git.rev_list(repo.active_branch.name, "--grep", escaped_message, "-n", "1")
|
|
343
350
|
|
|
@@ -362,7 +369,7 @@ def get_implementation_code_diff(repo_path: Union[str, os.PathLike], frid: str,
|
|
|
362
369
|
return _get_diff_dict(diff_output)
|
|
363
370
|
|
|
364
371
|
|
|
365
|
-
def get_fixed_implementation_code_diff(repo_path: Union[str, os.PathLike], frid: str) -> dict:
|
|
372
|
+
def get_fixed_implementation_code_diff(repo_path: Union[str, os.PathLike], frid: str) -> Optional[dict]:
|
|
366
373
|
repo = Repo(repo_path)
|
|
367
374
|
|
|
368
375
|
implementation_commit = _get_commit_with_message(repo, REFACTORED_CODE_COMMIT_MESSAGE.format(frid))
|
|
@@ -370,9 +377,20 @@ def get_fixed_implementation_code_diff(repo_path: Union[str, os.PathLike], frid:
|
|
|
370
377
|
implementation_commit = _get_commit_with_message(
|
|
371
378
|
repo, FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE.format(frid)
|
|
372
379
|
)
|
|
380
|
+
if not implementation_commit:
|
|
381
|
+
return None
|
|
373
382
|
|
|
374
|
-
|
|
375
|
-
|
|
383
|
+
escaped_passed_message = _escape_exact_grep_line(CONFORMANCE_TESTS_PASSED_COMMIT_MESSAGE)
|
|
384
|
+
escaped_frid_message = _escape_exact_grep_line(RENDERED_FRID_MESSAGE.format(frid))
|
|
385
|
+
conformance_tests_passed_commit = repo.git.rev_list(
|
|
386
|
+
repo.active_branch.name,
|
|
387
|
+
"--grep",
|
|
388
|
+
escaped_passed_message,
|
|
389
|
+
"--grep",
|
|
390
|
+
escaped_frid_message,
|
|
391
|
+
"--all-match",
|
|
392
|
+
"-n",
|
|
393
|
+
"1",
|
|
376
394
|
)
|
|
377
395
|
if not conformance_tests_passed_commit:
|
|
378
396
|
return None
|
tests/test_git_utils.py
CHANGED
|
@@ -8,10 +8,13 @@ from git import Repo
|
|
|
8
8
|
|
|
9
9
|
from git_utils import (
|
|
10
10
|
BASE_FOLDER_COMMIT_MESSAGE,
|
|
11
|
+
CONFORMANCE_TESTS_PASSED_COMMIT_MESSAGE,
|
|
11
12
|
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE,
|
|
13
|
+
FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE,
|
|
12
14
|
REFACTORED_CODE_COMMIT_MESSAGE,
|
|
13
15
|
add_all_files_and_commit,
|
|
14
16
|
diff,
|
|
17
|
+
get_fixed_implementation_code_diff,
|
|
15
18
|
get_last_rendered_functionality,
|
|
16
19
|
init_git_repo,
|
|
17
20
|
revert_changes,
|
|
@@ -508,3 +511,107 @@ def test_get_last_finished_frid_without_module_name(empty_repo):
|
|
|
508
511
|
|
|
509
512
|
with pytest.raises(InvalidGitRepositoryError, match="Could not find module name in finished commit"):
|
|
510
513
|
get_last_rendered_functionality(empty_repo)
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def test_get_fixed_implementation_code_diff_filters_by_specific_frid(empty_repo):
|
|
517
|
+
"""get_fixed_implementation_code_diff must return diff for the specific FRID,
|
|
518
|
+
and return None when an FRID has no conformance fix even if another FRID does."""
|
|
519
|
+
file_path = Path(empty_repo) / "code.py"
|
|
520
|
+
|
|
521
|
+
# FRID 1: implemented, then fixed during conformance tests
|
|
522
|
+
file_path.write_text("def f(): return 1\n")
|
|
523
|
+
add_all_files_and_commit(
|
|
524
|
+
empty_repo,
|
|
525
|
+
FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE.format("frid-1"),
|
|
526
|
+
module_name="mod",
|
|
527
|
+
frid="frid-1",
|
|
528
|
+
)
|
|
529
|
+
file_path.write_text("def f(): return 10\n")
|
|
530
|
+
add_all_files_and_commit(
|
|
531
|
+
empty_repo,
|
|
532
|
+
CONFORMANCE_TESTS_PASSED_COMMIT_MESSAGE,
|
|
533
|
+
module_name="mod",
|
|
534
|
+
frid="frid-1",
|
|
535
|
+
)
|
|
536
|
+
add_all_files_and_commit(
|
|
537
|
+
empty_repo,
|
|
538
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("frid-1"),
|
|
539
|
+
module_name="mod",
|
|
540
|
+
frid="frid-1",
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
# FRID 2: implemented and finished without any conformance fixes
|
|
544
|
+
file_path.write_text("def f(): return 10\ndef g(): return 2\n")
|
|
545
|
+
add_all_files_and_commit(
|
|
546
|
+
empty_repo,
|
|
547
|
+
FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE.format("frid-2"),
|
|
548
|
+
module_name="mod",
|
|
549
|
+
frid="frid-2",
|
|
550
|
+
)
|
|
551
|
+
add_all_files_and_commit(
|
|
552
|
+
empty_repo,
|
|
553
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("frid-2"),
|
|
554
|
+
module_name="mod",
|
|
555
|
+
frid="frid-2",
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
# FRID 2 has NO conformance fixes, so it must return None (not FRID 1's commit!)
|
|
559
|
+
assert get_fixed_implementation_code_diff(empty_repo, "frid-2") is None
|
|
560
|
+
|
|
561
|
+
# FRID 1 DOES have conformance fixes, so it must return FRID 1's diff
|
|
562
|
+
diff_frid_1 = get_fixed_implementation_code_diff(empty_repo, "frid-1")
|
|
563
|
+
assert diff_frid_1 is not None
|
|
564
|
+
assert "code.py" in diff_frid_1
|
|
565
|
+
assert "-def f(): return 1" in diff_frid_1["code.py"]
|
|
566
|
+
assert "+def f(): return 10" in diff_frid_1["code.py"]
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def test_get_fixed_implementation_code_diff_does_not_match_prefix_frids(empty_repo):
|
|
570
|
+
"""Exact line matching prevents FRID '1' (or 'add-item') from matching '10' (or 'add-item-v2')."""
|
|
571
|
+
file_path = Path(empty_repo) / "code.py"
|
|
572
|
+
|
|
573
|
+
# FRID "1": implemented and finished without conformance fixes
|
|
574
|
+
file_path.write_text("v = 1\n")
|
|
575
|
+
add_all_files_and_commit(
|
|
576
|
+
empty_repo,
|
|
577
|
+
FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE.format("1"),
|
|
578
|
+
module_name="mod",
|
|
579
|
+
frid="1",
|
|
580
|
+
)
|
|
581
|
+
add_all_files_and_commit(
|
|
582
|
+
empty_repo,
|
|
583
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("1"),
|
|
584
|
+
module_name="mod",
|
|
585
|
+
frid="1",
|
|
586
|
+
)
|
|
587
|
+
|
|
588
|
+
# FRID "10": implemented AND fixed during conformance testing
|
|
589
|
+
file_path.write_text("v = 10\n")
|
|
590
|
+
add_all_files_and_commit(
|
|
591
|
+
empty_repo,
|
|
592
|
+
FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE.format("10"),
|
|
593
|
+
module_name="mod",
|
|
594
|
+
frid="10",
|
|
595
|
+
)
|
|
596
|
+
file_path.write_text("v = 100\n")
|
|
597
|
+
add_all_files_and_commit(
|
|
598
|
+
empty_repo,
|
|
599
|
+
CONFORMANCE_TESTS_PASSED_COMMIT_MESSAGE,
|
|
600
|
+
module_name="mod",
|
|
601
|
+
frid="10",
|
|
602
|
+
)
|
|
603
|
+
add_all_files_and_commit(
|
|
604
|
+
empty_repo,
|
|
605
|
+
FUNCTIONAL_REQUIREMENT_FINISHED_COMMIT_MESSAGE.format("10"),
|
|
606
|
+
module_name="mod",
|
|
607
|
+
frid="10",
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
# FRID "1" must not match FRID "10"'s conformance fix commit
|
|
611
|
+
assert get_fixed_implementation_code_diff(empty_repo, "1") is None
|
|
612
|
+
|
|
613
|
+
# FRID "10" returns its own conformance fix diff
|
|
614
|
+
diff_10 = get_fixed_implementation_code_diff(empty_repo, "10")
|
|
615
|
+
assert diff_10 is not None
|
|
616
|
+
assert "-v = 10" in diff_10["code.py"]
|
|
617
|
+
assert "+v = 100" in diff_10["code.py"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|