imbi-plugin-github 2.9.2__py3-none-any.whl → 2.9.3__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.
- imbi_plugin_github/commits.py +56 -10
- {imbi_plugin_github-2.9.2.dist-info → imbi_plugin_github-2.9.3.dist-info}/METADATA +1 -1
- {imbi_plugin_github-2.9.2.dist-info → imbi_plugin_github-2.9.3.dist-info}/RECORD +6 -6
- {imbi_plugin_github-2.9.2.dist-info → imbi_plugin_github-2.9.3.dist-info}/WHEEL +0 -0
- {imbi_plugin_github-2.9.2.dist-info → imbi_plugin_github-2.9.3.dist-info}/entry_points.txt +0 -0
- {imbi_plugin_github-2.9.2.dist-info → imbi_plugin_github-2.9.3.dist-info}/licenses/LICENSE +0 -0
imbi_plugin_github/commits.py
CHANGED
|
@@ -565,20 +565,46 @@ async def _annotated_tag(
|
|
|
565
565
|
return typing.cast('dict[str, typing.Any]', resp.json())
|
|
566
566
|
|
|
567
567
|
|
|
568
|
+
def _web_base(api_base: str) -> str:
|
|
569
|
+
"""Map a REST API base to the web host (inverse of the routing table).
|
|
570
|
+
|
|
571
|
+
``https://api.github.com`` -> ``https://github.com``;
|
|
572
|
+
``https://api.<tenant>.ghe.com`` -> ``https://<tenant>.ghe.com``;
|
|
573
|
+
GHES ``https://<host>/api/v3`` -> ``https://<host>``.
|
|
574
|
+
"""
|
|
575
|
+
if api_base.endswith('/api/v3'):
|
|
576
|
+
return api_base[: -len('/api/v3')]
|
|
577
|
+
return api_base.replace('://api.', '://', 1)
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
def _tag_web_url(client: httpx.AsyncClient, name: str) -> str:
|
|
581
|
+
"""Build the web URL for *name* from the client's repo-scoped base."""
|
|
582
|
+
full = str(client.base_url).rstrip('/')
|
|
583
|
+
marker = '/repos/'
|
|
584
|
+
idx = full.find(marker)
|
|
585
|
+
if idx == -1:
|
|
586
|
+
return ''
|
|
587
|
+
web = _web_base(full[:idx])
|
|
588
|
+
owner_repo = full[idx + len(marker) :]
|
|
589
|
+
return f'{web}/{owner_repo}/releases/tag/{urllib.parse.quote(name)}'
|
|
590
|
+
|
|
591
|
+
|
|
568
592
|
def _tag_record(
|
|
569
593
|
*,
|
|
570
594
|
project_id: str,
|
|
571
595
|
name: str,
|
|
572
596
|
sha: str,
|
|
573
597
|
annotated: dict[str, typing.Any] | None = None,
|
|
598
|
+
url: str = '',
|
|
574
599
|
) -> TagRecord:
|
|
575
600
|
if annotated is None:
|
|
576
|
-
return TagRecord(project_id=project_id, name=name, sha=sha)
|
|
601
|
+
return TagRecord(project_id=project_id, name=name, sha=sha, url=url)
|
|
577
602
|
tagger: dict[str, typing.Any] = annotated.get('tagger') or {}
|
|
578
603
|
return TagRecord(
|
|
579
604
|
project_id=project_id,
|
|
580
605
|
name=name,
|
|
581
606
|
sha=sha,
|
|
607
|
+
url=url,
|
|
582
608
|
message=str(annotated.get('message') or ''),
|
|
583
609
|
tagger_name=str(tagger.get('name') or ''),
|
|
584
610
|
tagger_email=str(tagger.get('email') or ''),
|
|
@@ -589,22 +615,41 @@ def _tag_record(
|
|
|
589
615
|
async def _reconcile_tags(
|
|
590
616
|
client: httpx.AsyncClient, project_id: str
|
|
591
617
|
) -> list[TagRecord]:
|
|
592
|
-
"""Upsert the repo's full tag list
|
|
593
|
-
|
|
618
|
+
"""Upsert the repo's full tag list via the git-refs API.
|
|
619
|
+
|
|
620
|
+
``/git/matching-refs/tags`` yields each tag's object sha + type;
|
|
621
|
+
annotated tags (``type == 'tag'``) are enriched with tagger/message/
|
|
622
|
+
date from the tag object, lightweight tags carry name/sha/url only.
|
|
623
|
+
``ReplacingMergeTree`` dedupes against rows recorded from pushes.
|
|
624
|
+
"""
|
|
594
625
|
out: list[TagRecord] = []
|
|
626
|
+
prefix = 'refs/tags/'
|
|
595
627
|
params: dict[str, str] = {'per_page': '100'}
|
|
596
628
|
while True:
|
|
597
|
-
resp = await client.get('/tags', params=params)
|
|
629
|
+
resp = await client.get('/git/matching-refs/tags', params=params)
|
|
598
630
|
resp.raise_for_status()
|
|
599
631
|
rows = typing.cast('list[dict[str, typing.Any]]', resp.json())
|
|
600
632
|
for row in rows:
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
sha = str(
|
|
604
|
-
if
|
|
605
|
-
|
|
606
|
-
|
|
633
|
+
ref = str(row.get('ref') or '')
|
|
634
|
+
obj: dict[str, typing.Any] = row.get('object') or {}
|
|
635
|
+
sha = str(obj.get('sha') or '')
|
|
636
|
+
if not ref.startswith(prefix) or not sha:
|
|
637
|
+
continue
|
|
638
|
+
name = ref[len(prefix) :]
|
|
639
|
+
annotated = (
|
|
640
|
+
await _annotated_tag(client, sha)
|
|
641
|
+
if obj.get('type') == 'tag'
|
|
642
|
+
else None
|
|
643
|
+
)
|
|
644
|
+
out.append(
|
|
645
|
+
_tag_record(
|
|
646
|
+
project_id=project_id,
|
|
647
|
+
name=name,
|
|
648
|
+
sha=sha,
|
|
649
|
+
annotated=annotated,
|
|
650
|
+
url=_tag_web_url(client, name),
|
|
607
651
|
)
|
|
652
|
+
)
|
|
608
653
|
next_url = _next_page_url(resp.headers.get('link'))
|
|
609
654
|
if next_url is None:
|
|
610
655
|
return out
|
|
@@ -650,6 +695,7 @@ async def sync_tags(
|
|
|
650
695
|
name=name,
|
|
651
696
|
sha=after,
|
|
652
697
|
annotated=annotated,
|
|
698
|
+
url=_tag_web_url(client, name),
|
|
653
699
|
)
|
|
654
700
|
]
|
|
655
701
|
if action_config.reconcile_all:
|
|
@@ -2,12 +2,12 @@ imbi_plugin_github/__init__.py,sha256=8ZVhm8XpGqgYRUtpHl0uuZTT3gmMyHNhKd9k6qoatB
|
|
|
2
2
|
imbi_plugin_github/_app_auth.py,sha256=LnLrvqmu2UC27uHHJfIzFPNDh33RtgeOX1RXceX9Pj0,7000
|
|
3
3
|
imbi_plugin_github/_hosts.py,sha256=jQ1Z6yEpjAa4b7LocLfEelnBcRYYQLNLBNCdWZtAXUc,2258
|
|
4
4
|
imbi_plugin_github/_repos.py,sha256=agp4ZgRuqbrGBRMFeHomnUf1HvvaNvapBCWHQebdviQ,4559
|
|
5
|
-
imbi_plugin_github/commits.py,sha256=
|
|
5
|
+
imbi_plugin_github/commits.py,sha256=LXC2dkPIMmPxyB3FKujD_6nTE3F0CVux-v3nI72Q-QE,31549
|
|
6
6
|
imbi_plugin_github/deployment.py,sha256=V6YlZX24m33BPJWkC-vCZZLSsH71etkl0xkhkDsKASg,47914
|
|
7
7
|
imbi_plugin_github/identity.py,sha256=RSs1cLQpZmfyQ_0KQkohDIZEBYVBnre6RJIt166EtdQ,15525
|
|
8
8
|
imbi_plugin_github/lifecycle.py,sha256=48mLKjFPG7BOanpA7jWnmbWOdsDLh1F39g2AoxDLL7M,33211
|
|
9
|
-
imbi_plugin_github-2.9.
|
|
10
|
-
imbi_plugin_github-2.9.
|
|
11
|
-
imbi_plugin_github-2.9.
|
|
12
|
-
imbi_plugin_github-2.9.
|
|
13
|
-
imbi_plugin_github-2.9.
|
|
9
|
+
imbi_plugin_github-2.9.3.dist-info/METADATA,sha256=eLq2egFOhfiG4vxXTSkm6zcX73RpF0je4Pt8i5IG2X0,5809
|
|
10
|
+
imbi_plugin_github-2.9.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
11
|
+
imbi_plugin_github-2.9.3.dist-info/entry_points.txt,sha256=RavN_FYCeS97iauHgCG3tHFdVULbEMXmQfvgCgLeGkI,805
|
|
12
|
+
imbi_plugin_github-2.9.3.dist-info/licenses/LICENSE,sha256=el9B20zOqEcv_mRrHgbdkVyxSC6I8np7am0D6mO2A9Y,1491
|
|
13
|
+
imbi_plugin_github-2.9.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|