Skip to content

Commit cf4c25a

Browse files
author
Jieli
committed
fix: send claude code repo url
Codex-Thread-ID: https://jieli.app/threads/T-019eacb5-a5bc-7b72-a4d6-ee11eb7112ec
1 parent 07b19cc commit cf4c25a

3 files changed

Lines changed: 13 additions & 36 deletions

File tree

plugins/claude-code/.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "claude-code",
33
"displayName": "Jieli Claude Code Sync",
4-
"version": "0.1.3",
4+
"version": "0.1.4",
55
"description": "Sync Claude Code sessions to Jieli threads and attach Jieli thread trailers to Claude-created commits.",
66
"author": {
77
"name": "Jieli"

plugins/claude-code/scripts/sync.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def build_payload_from_hook(hook_data: dict[str, Any], base_url: str | None = No
109109
thread_payload["resolved_model"] = resolved_model
110110
return {
111111
"provider": PROVIDER,
112-
"repo": repo_from_cwd(cwd),
112+
"repo": "",
113+
"repo_url": repo_url_from_cwd(cwd),
113114
"branch": branch,
114115
"source_url": source_url,
115116
"labels": [],
@@ -545,7 +546,7 @@ def title_from_messages(messages: list[dict[str, Any]]) -> str:
545546
return "Claude Code session"
546547

547548

548-
def repo_from_cwd(cwd: str) -> str:
549+
def repo_url_from_cwd(cwd: str) -> str:
549550
try:
550551
result = subprocess.run(
551552
["git", "config", "--get", "remote.origin.url"],
@@ -558,34 +559,7 @@ def repo_from_cwd(cwd: str) -> str:
558559
)
559560
except (OSError, subprocess.TimeoutExpired):
560561
return ""
561-
if result.returncode != 0:
562-
return ""
563-
return repo_from_repository_url(result.stdout)
564-
565-
566-
def repo_from_repository_url(raw: str) -> str:
567-
value = raw.strip().rstrip("/")
568-
if value.endswith(".git"):
569-
value = value[:-4]
570-
prefixes = (
571-
"https://github.com/",
572-
"http://github.com/",
573-
"git@github.com:",
574-
"ssh://git@github.com/",
575-
)
576-
for prefix in prefixes:
577-
if value.startswith(prefix):
578-
return valid_github_repo_slug(value[len(prefix) :])
579-
return ""
580-
581-
582-
def valid_github_repo_slug(value: str) -> str:
583-
parts = value.split("/")
584-
if len(parts) != 2:
585-
return ""
586-
if all(re.fullmatch(r"[A-Za-z0-9_.-]+", part) for part in parts):
587-
return value
588-
return ""
562+
return result.stdout.strip() if result.returncode == 0 else ""
589563

590564

591565
def timestamp_ms(value: Any) -> int:

plugins/claude-code/tests/test_plugin_scripts.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def test_build_payload_from_claude_jsonl_redacts_secrets_and_skips_non_messages(
240240
self.assertEqual(payload["provider"], "claude_code")
241241
self.assertEqual(payload["labels"], [])
242242
self.assertEqual(payload["repo"], "")
243+
self.assertEqual(payload["repo_url"], "")
243244
self.assertEqual(payload["branch"], "plugin/sync")
244245
self.assertEqual(payload["source_url"], "https://jieli.example.test/threads/T-cc-1")
245246
self.assertEqual(payload["thread"]["id"], "T-cc-1")
@@ -255,15 +256,15 @@ def test_build_payload_from_claude_jsonl_redacts_secrets_and_skips_non_messages(
255256
self.assertNotIn("abc.def.ghi", raw_payload)
256257
self.assertNotIn("tool.secret", raw_payload)
257258

258-
def test_build_payload_uses_git_remote_repo_slug(self):
259+
def test_build_payload_includes_raw_repo_url_from_git_remote(self):
259260
from sync import build_payload_from_hook
260261

261262
with tempfile.TemporaryDirectory() as tmpdir:
262-
repo = Path(tmpdir) / "github" / "plugins"
263+
repo = Path(tmpdir) / "repo"
263264
repo.mkdir(parents=True)
264265
subprocess.run(["git", "init"], cwd=repo, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
265266
subprocess.run(
266-
["git", "remote", "add", "origin", "git@github.com:jieliapp/plugins.git"],
267+
["git", "remote", "add", "origin", "git@home.pika12.com:guoyb/jieli.git"],
267268
cwd=repo,
268269
check=True,
269270
stdout=subprocess.DEVNULL,
@@ -291,9 +292,10 @@ def test_build_payload_uses_git_remote_repo_slug(self):
291292
base_url="https://jieli.example.test",
292293
)
293294

294-
self.assertEqual(payload["repo"], "jieliapp/plugins")
295+
self.assertEqual(payload["repo"], "")
296+
self.assertEqual(payload["repo_url"], "git@home.pika12.com:guoyb/jieli.git")
295297

296-
def test_build_payload_leaves_repo_empty_without_github_remote(self):
298+
def test_build_payload_leaves_repo_metadata_empty_without_git_remote(self):
297299
from sync import build_payload_from_hook
298300

299301
with tempfile.TemporaryDirectory() as tmpdir:
@@ -322,6 +324,7 @@ def test_build_payload_leaves_repo_empty_without_github_remote(self):
322324
)
323325

324326
self.assertEqual(payload["repo"], "")
327+
self.assertEqual(payload["repo_url"], "")
325328

326329
def test_build_payload_uploads_structured_image_blocks(self):
327330
from sync import build_payload_from_hook

0 commit comments

Comments
 (0)