Skip to content

PR・Issue本文の行差分編集CLIを追加 - #1

Merged
s4na merged 3 commits into
mainfrom
feat/github-body-providers
Sep 24, 2026
Merged

s4na merged 3 commits into
mainfrom
feat/github-body-providers

Conversation

@s4na

@s4na s4na commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

目的

provider 経由で取得したテキストを行単位で編集し、差分確認後に反映します。まず GitHub PR・Issue 本文に対応します。

変更

  • gh-pr-body と gh-issue-body provider
  • 指定行と旧内容を照合し、差分表示・確認後に更新
  • 更新直前の再取得で同時編集を検知
  • 末尾改行なし・UTF-8・CRLF に対応
  • GitHub Actions で Ruff と unittest を実行

検証

  • python -m ruff check .:成功
  • python -W error -m unittest discover -s tests:10件成功
  • GitHub Actions の test-and-lint:成功
  • 実 API 更新は gh が作業環境にないため未実行

事前レビュー・規模

全差分を確認。Python 標準ライブラリと gh を使用し、CI は1ジョブに限定。旧内容の不一致、キャンセル、同時編集で更新しないことを検証しました。zizmor は後続 PR に分けます。

制約

本文全体を送信するため、再取得と更新の間の同時編集は完全には防げません。空の本文への挿入は未対応です。

by ChatGPT

s4na commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T09:13:12.639029Z 8daef3d New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 38f1022f87

ℹ️ 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 textdiffedit/cli.py Outdated
Comment on lines +82 to +84
diff = difflib.unified_diff(original.splitlines(keepends=True), updated.splitlines(keepends=True),
fromfile="before", tofile="after")
sys.stdout.writelines(diff)

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 Preserve line boundaries when rendering the diff

When the selected final line has no trailing newline—an explicitly supported case—the keepends=True entries also lack terminators, so writelines() concatenates deletion and addition records (for example, -old+new) and may attach the confirmation prompt to that same line. This produces a malformed and potentially misleading diff at the exact point where the user is expected to review the update; add explicit line separators or a no-newline marker when rendering such records.

Useful? React with 👍 / 👎.

Comment thread textdiffedit/cli.py Outdated
def request(self, *args, input_text=None):
try:
result = subprocess.run(
["gh", "api", self.path, *args], input=input_text, text=True,

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 Pin API requests to the validated URL's host

When the caller has GH_HOST set for a GitHub Enterprise instance, this path-only invocation sends the request to that host rather than to github.com, even though the accepted URL explicitly names github.com; gh api --help documents this behavior as GH_HOST: make the request to a GitHub host other than "github.com". The command will therefore fail against the wrong server or could read and update a same-named repository there, so pass --hostname github.com (or derive the hostname from the validated URL).

Useful? React with 👍 / 👎.

Comment thread textdiffedit/cli.py Outdated
Comment on lines +31 to +32
["gh", "api", self.path, *args], input=input_text, text=True,
capture_output=True, check=True,

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 Decode GitHub API output explicitly as UTF-8

On systems whose default locale is not UTF-8, notably many Windows Python 3.10 installations, text=True decodes gh's UTF-8 JSON using the locale encoding. A body containing non-ASCII text can therefore raise UnicodeDecodeError or become mojibake; because the edit files are also read with the locale default, validation can even pass before json.dumps() uploads those corrupted characters. Set encoding="utf-8" on the subprocess and use the same explicit encoding when reading both edit files.

Useful? React with 👍 / 👎.

s4na commented Sep 24, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 1362a8798b

ℹ️ 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".

@s4na
s4na merged commit 7565865 into main Sep 24, 2026
1 check passed
@s4na
s4na deleted the feat/github-body-providers branch September 24, 2026 09:34
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.

1 participant