Skip to content

Add GetBlame API#24

Open
rkdud007 wants to merge 5 commits intomainfrom
pia/get-git--blame
Open

Add GetBlame API#24
rkdud007 wants to merge 5 commits intomainfrom
pia/get-git--blame

Conversation

@rkdud007
Copy link
Copy Markdown
Collaborator

@rkdud007 rkdud007 commented May 6, 2026

implemented sdk corresponds with https://github.com/pierredotco/monorepo/pull/1235

rkdud007 and others added 2 commits May 5, 2026 16:58
Wire the GET /api/v1/repos/blame gateway endpoint into all three SDKs as
`Repo.getBlame` (TS), `Repo.get_blame` (Python), and `Repo.GetBlame` (Go),
mirroring the GetCommit (#20) integration shape — required `path`, optional
`ref`/`ephemeral`/`start_line`/`end_line`/`detect_moves`, JWT minted with
`git:read`, response transformed from snake_case wire to camelCase result.

The response surfaces a top-level `commit` (the SHA the input ref resolved to)
distinct from `commits` (deduped per-authoring-commit metadata referenced by
`lines[]`). Author and committer timestamps are parsed to native date types
while preserving the raw RFC strings. SKILL.md and the TS/Python READMEs
document the endpoint, two-step `lines → commits` lookup, and that omitting
`ref` falls back to the repository default branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The initial GetBlame implementation in all three SDKs decoded against the
storage-layer connectrpc proto shape, but the gateway HTTP route flattens
that before it goes on the wire. Production responses would have failed
to parse (TS zod, Python KeyError) or silently dropped per-line author
metadata (Go).

Reshape the SDK types to the gateway shape (gateway/internal/gitapi/blame.go):

- Top-level field renamed `commit` -> `commit_sha`.
- `lines[]` carries `previous_commit_sha`, `author_*`, `committer_*`, and
  `summary` inline; the separate top-level `commits` map is gone.
- The nonexistent `text` field is removed from BlameLine.
- BlameCommit type / TypedDict / struct is dropped.

Updates the SKILL.md response example and unit tests across all three
packages to the same shape. Verified against the monorepo gateway
TestBlameResponse_JSONFieldNames golden JSON.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rkdud007 rkdud007 marked this pull request as ready for review May 8, 2026 00:13
@rkdud007 rkdud007 requested a review from unknwon May 8, 2026 00:14
@unknwon
Copy link
Copy Markdown
Contributor

unknwon commented May 8, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@unknwon
Copy link
Copy Markdown
Contributor

unknwon commented May 8, 2026

The ones reported by Claude seems valid?

1. README examples reference fields the SDK doesn't return. Both packages/code-storage-typescript/README.md and packages/code-storage-python/README.md show:

const author = blame.commits[line.commitSha];
console.log(`${line.lineNumber}: ${author.authorName}\t${line.text}`);

Neither BlameResult.commits nor BlameLine.text exists in the implementation. Users copy-pasting will hit undefined / KeyError.

2. TS README's BlameResult interface block contradicts the exported type. README declares commit: string and a commits: Record<string, BlameCommit> field with a BlameCommit type — none of which exist in src/types.ts. The real type is { ref, path, commitSha, lines }.

3. Possible schema rejection of valid server responses. blameLineRawSchema marks original_line_number and original_path as required. SKILL.md notes previous_commit_sha is omitted for lines with no prior version — that's handled. But if the server also omits original_* for unmoved lines (common in blame APIs), z.parse will throw. Worth verifying against the monorepo PR; ignore if the server always sends them.

@unknwon
Copy link
Copy Markdown
Contributor

unknwon commented May 8, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce5100824c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/code-storage-typescript/README.md Outdated
Comment thread packages/code-storage-python/README.md Outdated
@rkdud007
Copy link
Copy Markdown
Collaborator Author

rkdud007 commented May 8, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dac2f1c82d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/code-storage-typescript/src/index.ts Outdated
@rkdud007
Copy link
Copy Markdown
Collaborator Author

rkdud007 commented May 8, 2026

@codex review

@unknwon
Copy link
Copy Markdown
Contributor

unknwon commented May 8, 2026

@codex review

@unknwon
Copy link
Copy Markdown
Contributor

unknwon commented May 8, 2026

It seems dead 😂

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e7c65d3dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +475 to +476
// BlameOptions configures a per-line blame lookup.
type BlameOptions struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document the Go blame API

Adding BlameOptions/Repo.GetBlame changes the public Go SDK surface, but packages/code-storage-go/README.md still has no blame/GetBlame mention (checked with rg). The root AGENTS.md says to "Update docs when public API shapes change", and the TypeScript/Python READMEs were updated in this commit, so Go users are left without the new method's options/response shape or an example.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants