theskumar / theskumar/python-dotenv
dotenv-cli - rewrite() does not resolve symlinks
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 8.9k
- フォーク
- 581
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
While having a play around w/ dotenv today, I noticed that if my .env file was symlinked elsewhere, using the CLI utility via dotenv set or dotenv unset would not work as I expected it to, so I made this small change to the rewrite function:
diff --git a/src/dotenv/main.py b/src/dotenv/main.py
index 052de05..3606abe 100644
--- a/src/dotenv/main.py
+++ b/src/dotenv/main.py
@@ -132,8 +132,12 @@ def rewrite(
path: StrPath,
encoding: Optional[str],
) -> Iterator[Tuple[IO[str], IO[str]]]:
- pathlib.Path(path).touch()
+ path = pathlib.Path(path)
+ if path.is_symlink():
+ path = path.resolve()
+
+ path.touch()
with tempfile.NamedTemporaryFile(mode="w", encoding=encoding, delete=False) as dest:
error = None
try:
This does what I want, but I'm not sure if there are disadvantages to this. I know symlinks are more widely used on linux, but if I'm not mistaken I think this would work on Windows too, since dotenv works with files and not directories.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Start in src/dotenv/main.py at the rewrite() function and review how dotenv set and dotenv unset handle a symlinked .env path. Verify the behavior with a symlinked file on the supported platforms; done means those CLI operations update the target file as expected without breaking regular paths.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- cli
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 48/100