codeimprint 0.5.0a27__tar.gz → 0.5.0a28__tar.gz

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.
Files changed (26) hide show
  1. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/CHANGELOG.md +12 -0
  2. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/PKG-INFO +1 -1
  3. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/pyproject.toml +1 -1
  4. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/__init__.py +1 -1
  5. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/cli.py +33 -1
  6. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/.gitignore +0 -0
  7. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/LICENSE +0 -0
  8. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/NOTICE +0 -0
  9. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/README.pypi.md +0 -0
  10. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint/__init__.py +0 -0
  11. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint/__main__.py +0 -0
  12. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/__main__.py +0 -0
  13. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/api.py +0 -0
  14. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/chainseal.py +0 -0
  15. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/config.py +0 -0
  16. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/gitrepo.py +0 -0
  17. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/imprint_file.py +0 -0
  18. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/linecount.py +0 -0
  19. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/ownership.py +0 -0
  20. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/project.py +0 -0
  21. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/receipt.py +0 -0
  22. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/records.py +0 -0
  23. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/timestamp.py +0 -0
  24. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/transparency.py +0 -0
  25. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/trust.py +0 -0
  26. {codeimprint-0.5.0a27 → codeimprint-0.5.0a28}/src/codeimprint_cli/tsa_roots.py +0 -0
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0a28 — `imprint init` and the GitHub App [CIM-BE-41-v1]
4
+
5
+ For engine 0.7.0a33.
6
+
7
+ - **Changed: `imprint init` adds no CI workflow when the CodeImprint GitHub App already seals
8
+ the repository** (its key is authorised on the project), and says so: "This repository is
9
+ sealed by the GitHub App; no CI workflow added." Anything unknown (not signed in, an older
10
+ engine, no answer, the App not yet authorised) adds the workflow as before.
11
+ - **New: `imprint init --ci`** adds the workflow anyway. `--ci` and `--no-ci` together are
12
+ refused.
13
+ - Tests: `tests/test_repository.py`.
14
+
3
15
  ## 0.5.0a27 — One project per repository; archiving a duplicate [CIM-BE-40-v1]
4
16
 
5
17
  For engine 0.7.0a32.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: codeimprint
3
- Version: 0.5.0a27
3
+ Version: 0.5.0a28
4
4
  Summary: CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline.
5
5
  Project-URL: Homepage, https://codeimprint.ai
6
6
  Project-URL: Hub, https://app.codeimprint.ai
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
  # Published on PyPI as `codeimprint`. The import package stays `codeimprint_cli` and the
7
7
  # command `imprint`.
8
8
  name = "codeimprint"
9
- version = "0.5.0a27"
9
+ version = "0.5.0a28"
10
10
  description = "CodeImprint: seal your code with a CodeImprint server (tamper-evident, logged and timestamped) and verify seals offline."
11
11
  readme = "README.pypi.md"
12
12
  license = "Apache-2.0"
@@ -5,4 +5,4 @@ A thin client for a CodeImprint server: it zips a project, asks the server to se
5
5
  it, and verifies Imprint files offline. All analysis happens on the server.
6
6
  """
7
7
 
8
- __version__ = "0.5.0a27"
8
+ __version__ = "0.5.0a28"
@@ -583,10 +583,15 @@ def cmd_login(args) -> int:
583
583
  return 0
584
584
 
585
585
 
586
+ APP_SEALS = "This repository is sealed by the GitHub App; no CI workflow added."
587
+
588
+
586
589
  def cmd_init(args) -> int:
587
590
  root = Path(args.path).resolve()
588
591
  if not root.is_dir():
589
592
  raise Abort(f"no such folder: {root}")
593
+ if getattr(args, "ci", False) and args.no_ci:
594
+ raise Abort("choose one: --ci adds the build workflow, --no-ci leaves it out")
590
595
  cfg_path = root / project.CONFIG_DIR / project.CONFIG_FILE
591
596
  existing = project.load_config(root)
592
597
  link = getattr(args, "link_origin", False)
@@ -637,7 +642,11 @@ def cmd_init(args) -> int:
637
642
  _say(f"updated {cfg_path.relative_to(root).as_posix()} (developer key)")
638
643
  else:
639
644
  write(cfg_path, json.dumps(cfg, indent=2) + "\n")
640
- if not args.no_ci:
645
+ ci = not args.no_ci
646
+ if ci and not getattr(args, "ci", False) and _app_seals_here(args, root, existing):
647
+ ci = False # every push is sealed already (CIM-BE-41-v1)
648
+ _say(f"skipped CI workflow: {APP_SEALS} (`imprint init --ci` adds it anyway)")
649
+ if ci:
641
650
  rel, text, shared = ci_file(root, cfg["fail_above"])
642
651
  if shared and (root / rel).exists(): # the repository's one pipeline file
643
652
  _say(f"kept {rel} (it is your pipeline: add the CodeImprint job from the "
@@ -665,6 +674,26 @@ def cmd_init(args) -> int:
665
674
  return 0
666
675
 
667
676
 
677
+ def _app_seals_here(args, root: Path, existing: dict) -> bool:
678
+ """The CodeImprint GitHub App seals this repository's project with an authorised key,
679
+ so a CI workflow would seal every push twice. Asked of the server for the signed-in
680
+ account's own projects here; anything unknown (no server, not signed in, an engine
681
+ before 0.7.0a33, no answer) counts as no, and the workflow is added as before."""
682
+ ident = _identity(root)
683
+ settings = config.resolve(getattr(args, "url", None))
684
+ if not ident or not settings.url:
685
+ return False
686
+ try:
687
+ client = _signed_in(settings.url, settings.token)
688
+ if client.auth != "session":
689
+ return False
690
+ items = client.own_projects_here(ident)
691
+ except (ApiError, NetworkError, Abort):
692
+ return False
693
+ named = [i for i in items if i["project_id"] == existing.get("project_id")]
694
+ return any(i.get("github_app_seals") for i in (named or items))
695
+
696
+
668
697
  def _origin_place(args, root: Path, existing: dict) -> tuple[str, str | None]:
669
698
  """For `imprint init` in a folder whose config already names a project: is this the
670
699
  repository that project lives in ("same", "different" or "unknown"), and why the project
@@ -3120,6 +3149,9 @@ def build_parser() -> argparse.ArgumentParser:
3120
3149
  n.add_argument("path", nargs="?", default=".")
3121
3150
  n.add_argument("--no-ci", action="store_true", help="do not add a build workflow (GitHub Actions, GitLab "
3122
3151
  "CI or Bitbucket Pipelines, by the remote)")
3152
+ n.add_argument("--ci", action="store_true",
3153
+ help="add the build workflow even when the CodeImprint GitHub App already "
3154
+ "seals this repository")
3123
3155
  n.add_argument("--no-key", action="store_true", help="do not create a developer key")
3124
3156
  n.add_argument("--force", action="store_true", help="overwrite files that already exist")
3125
3157
  n.add_argument("--url", help="server URL for creating the project (else login or "
File without changes
File without changes