Skip to content

Commit

Permalink
Deduce register name from github repo
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Jan 9, 2024
1 parent 5b343ac commit 9b25b86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ogc/bblocks/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@

base_url = args.base_url
github_base_url = args.github_base_url
git_repo_path = None
if not base_url or not github_base_url:
try:
import git
repo = git.Repo()
git_repo_path = Path(repo.working_dir)
remote_branch = repo.active_branch.tracking_branch()
remote = repo.remote(remote_branch.remote_name)
remote_url = next(remote.urls)
Expand Down Expand Up @@ -190,7 +192,8 @@
github_base_url=github_base_url,
imported_registers=imported_registers,
bb_filter=args.filter,
steps=steps)
steps=steps,
git_repo_path=git_repo_path)

# 2. Uplift register.json
print(f"Running semantic uplift of {register_file}", file=sys.stderr)
Expand Down
5 changes: 4 additions & 1 deletion ogc/bblocks/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def postprocess(registered_items_path: str | Path = 'registereditems',
imported_registers: list[str] | None = None,
bb_filter: str | None = None,
steps: list[str] | None = None,
bbr_config: dict | None = None) -> list[dict]:
bbr_config: dict | None = None,
git_repo_path: Path | None = None) -> list[dict]:

cwd = Path().resolve()

Expand Down Expand Up @@ -299,6 +300,8 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
}
if bbr_config.get('name'):
output_register_json['name'] = bbr_config['name']
elif git_repo_path:
output_register_json['name'] = git_repo_path.name
if base_url:
output_register_json['baseURL'] = base_url
if full_validation_report_url:
Expand Down

0 comments on commit 9b25b86

Please sign in to comment.