Repository navigation
PR・Issue本文の行差分編集CLIを追加 - #1
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| diff = difflib.unified_diff(original.splitlines(keepends=True), updated.splitlines(keepends=True), | ||
| fromfile="before", tofile="after") | ||
| sys.stdout.writelines(diff) |
There was a problem hiding this comment.
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 👍 / 👎.
| def request(self, *args, input_text=None): | ||
| try: | ||
| result = subprocess.run( | ||
| ["gh", "api", self.path, *args], input=input_text, text=True, |
There was a problem hiding this comment.
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 👍 / 👎.
| ["gh", "api", self.path, *args], input=input_text, text=True, | ||
| capture_output=True, check=True, |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
目的
provider 経由で取得したテキストを行単位で編集し、差分確認後に反映します。まず GitHub PR・Issue 本文に対応します。
変更
gh-pr-bodyとgh-issue-bodyprovider検証
python -m ruff check .:成功python -W error -m unittest discover -s tests:10件成功ghが作業環境にないため未実行事前レビュー・規模
全差分を確認。Python 標準ライブラリと gh を使用し、CI は1ジョブに限定。旧内容の不一致、キャンセル、同時編集で更新しないことを検証しました。zizmor は後続 PR に分けます。
制約
本文全体を送信するため、再取得と更新の間の同時編集は完全には防げません。空の本文への挿入は未対応です。
by ChatGPT