codeant-ai-for-open-source[bot] commented on code in PR #44578:
URL: https://github.com/apache/superset/pull/44578#discussion_r4085662280
##########
scripts/translations/check_pot_drift.py:
##########
@@ -99,16 +99,77 @@ def _msgid_set(pot_path: Path) -> set[MsgId]:
}
-def extract_fresh(output_path: Path) -> None:
- """Run the project's extraction command into ``output_path``."""
- subprocess.run( # noqa: S603
- ["pybabel", "extract", "-F", str(BABEL_CFG), "-o", str(output_path)]
- + EXTRACT_FLAGS,
+def _archive_ref() -> str:
+ """Return a tree-ish for ``git archive`` that matches the working tree.
+
+ ``git stash create`` builds a commit object for the current index and
+ tracked-file modifications without touching the working tree, any ref,
+ or the actual stash, so it is safe to call while other processes are
+ using this checkout. It prints nothing when there is nothing to stash,
+ so fall back to ``HEAD``.
+
+ Deliberately uses ``Popen`` rather than ``run``: this module's tests
+ patch ``subprocess.run`` to fake the single "run pybabel" call, and a
+ second real ``run`` call here would be caught by that same patch.
+ """
+ proc = subprocess.Popen( # noqa: S603
+ ["git", "stash", "create"], # noqa: S607
cwd=ROOT_DIR,
- check=True,
- capture_output=True,
+ stdout=subprocess.PIPE,
text=True,
)
+ stash_sha, _ = proc.communicate()
+ if proc.returncode != 0:
+ raise subprocess.CalledProcessError(proc.returncode, proc.args)
+ return stash_sha.strip() or "HEAD"
+
+
+def extract_fresh(output_path: Path) -> None:
+ """Run the project's extraction command into ``output_path``.
+
+ Extracts from a ``git archive`` snapshot rather than the live checkout.
+ The Python-Unit job runs ``pytest -n auto --dist loadfile``, so many
+ worker processes share this checkout while this test runs; ``pybabel
+ extract`` walks everything under ``cwd``, so scanning the working
+ directory directly makes the msgid set depend on whatever transient
+ files another worker's test happens to write into the tree at that
+ instant.
+ """
+ with tempfile.TemporaryDirectory() as snapshot_dir_str:
+ snapshot_dir = Path(snapshot_dir_str)
+ archive = subprocess.Popen( # noqa: S603
+ ["git", "archive", _archive_ref()], # noqa: S607
Review Comment:
**Suggestion:** `git stash create` excludes untracked files, so a new
untranslated source file not yet added to Git is omitted and the check can
falsely report no drift.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=2c30bf8f76344b38b59ab68933f87937&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=2c30bf8f76344b38b59ab68933f87937&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** scripts/translations/check_pot_drift.py
**Line:** 141:141
**Comment:**
*Api Mismatch: `git stash create` excludes untracked files, so a new
untranslated source file not yet added to Git is omitted and the check can
falsely report no drift.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44578&comment_hash=61f966172edae332f609061f0b5fd400583da4c107091ba0e9c5a2d52544ba29&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44578&comment_hash=61f966172edae332f609061f0b5fd400583da4c107091ba0e9c5a2d52544ba29&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]