Conversation
Importing a `.env` flattened every comment in it into one notes block, so the note explaining a variable ended up several screens away from it, and copying the item back out produced a document regenerated from its fields: keys in the item's order, every value quoted, no comments at all. For a file somebody maintains by hand, that is not the same file. An item now stores the shape of the `.env` it came from — comments, blank lines, ordering, indentation, `export` prefixes, quoting, and which values were written across several lines — and no values at all. A value lives only in its field, so the layout cannot become a stale second copy of a secret, and rendering means putting the current fields back into the owner's own file. It needs no access to the file, so it works from a backup and on another Mac. - Copy .env now reproduces that file. Copy .env Values Only (⇧⌥⌘E) keeps the keys-and-values form for anything that strips comments anyway. - The detail pane reads the comments the way the file does: banner blocks become headings, a block above a run of variables introduces that run, and a `# note` after a value sits under that value. - The layout is captured on import, on every pull, and when a file is linked, which is how an item imported by an earlier version picks it up. - Pulling a file no longer overwrites the item's notes. Notes are the owner's; the file's comments have somewhere better to live now. - A variable the item no longer holds renders as no line at all rather than as an empty assignment, and one added in PassStore is appended. - An empty value keeps the bare `KEY=` form when that is what the file used. Vaults written by earlier versions decode with no layout and behave exactly as they did.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5 — review that one first; this PR's diff is against
fix/env-write-fidelity.Why
Importing a
.envflattened every comment in the file into one notes block. The note explaining a variable ended up several screens away from the variable, and a file with section banners came out as an unreadable wall of text. Copying the item back out was worse: the document was regenerated from the item's fields — keys in the item's order, every value quoted, no comments — which for a file somebody maintains by hand is simply a different file.Reported by a user who keeps his
.envfiles commented per variable and wanted to move one to another machine with its notes intact. He also uses the stripped form, because some tools discard comments anyway — so this is two outputs, not one setting.How
An item now stores the shape of the
.envit came from and no values: comments, blank lines, ordering, indentation,exportprefixes, the quoting each value had, and which values were written across several lines. A value lives in exactly one place — its field — so the layout can never become a stale second copy of a secret. Rendering a document means putting the current fields back into the owner's own file, which needs no access to that file: it works from a backup, on another Mac, and when the original is gone.# noteafter a value appears under that value. Getting this reading wrong could only ever misplace a comment on screen — the file itself is reproduced from the stored lines, never from this interpretation of them.KEY=form where that is what the file used.envContents— what the sync digests are computed from — deliberately stays values-only. Making it layout-aware would have made every already-linked item look like it had changed the moment this shipped, and invited a push nobody asked for.Compatibility
envLayoutis a new optional field on the item snapshot, decoded withdecodeIfPresent. Vaults written by earlier versions load with no layout and behave exactly as before. Structural size is capped with the rest of the vault's resource limits.Tests
New
EnvLayoutTests/EnvLayoutIntegrationTests: byte-for-byte reproduction of a realistic commented file (banners, indentedexport, single quotes, a trailing comment, an empty value, a wrapped PEM key); a changed value altering exactly one line; a removed variable leaving no stale line; an added one appended; a wrapped value staying wrapped; the comment-to-variable reading; layout surviving a snapshot round-trip; an older snapshot decoding without one; copy-after-import returning the original file; a pull leaving notes alone; linking teaching an older item its formatting; and editing or duplicating an item keeping it.