Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for 'changes' and trailing newlines, for #291 #293

Merged
merged 19 commits into from
Jan 1, 2019
Merged

Fixes for 'changes' and trailing newlines, for #291 #293

merged 19 commits into from
Jan 1, 2019

Conversation

joshrabinowitz
Copy link
Collaborator

@joshrabinowitz joshrabinowitz commented Dec 29, 2018

@sobolevn @BrandonCsSanders I think issue #291 & PR #292 might not be relevant for git-secret master.

I cannot reproduce #291 in my tests with git-secret master, (see the test "run 'changes' with no file changed" in tests/test_changes.bats )

Also I did some experimenting with #292 and master and I'm not sure it improves things.
(See new comments in src/commands/git_secret_changes.sh]

Am I missing something? Is there an issue with git-secret changes in master?

Edit: This fixes bugs in 'git secret changes' related to trailing newlines in file contents.
For details see the comments in #291

  [tests/test_changes.bats]
  using BATS_TEST_DESCRIPTION env var

  [tests/test_changes.bats, tests/test_expiration.bats,
   tests/test_hide.bats, tests/test_whoknows.bats]
@joshrabinowitz
Copy link
Collaborator Author

@sobolevn look at this output in (for example) https://travis-ci.org/sobolevn/git-secret/jobs/473335843

"# 'run 'changes' on two files with no file changed' output: changes in /tmp/space file:", 
"# 'run 'changes' on two files with no file changed' output: ", 
"# 'run 'changes' on two files with no file changed' output: changes in /tmp/space file two:", 
"# 'run 'changes' on two files with no file changed': num lines is 3", 
"ok 16 run 'changes' on two files with no file changed", 

Should there be only 2 lines output instead of 3?

@sobolevn
Copy link
Owner

@joshrabinowitz yes, looks like so.

  [src/commands/git_secret_changes.sh]
  [tests/_test_base.bash, tests/test_cat.bats]
  [src/commands/git_secret_changes.sh]
@joshrabinowitz
Copy link
Collaborator Author

joshrabinowitz commented Dec 31, 2018

I figured out the issue (but not the solution) to #291.

The underlying issue is that the $() construct used in
decrypted=$(_decrypt "$path" "0" "0" "$homedir" "$passphrase") (and elsewhere)
removes trailing newlines.

  [src/commands/git_secret_changes.sh, tests/_test_base.bash]
  [src/commands/git_secret_changes.sh, tests/test_changes.bats]
  [src/commands/git_secret_changes.sh]
  also test 'changes' when called on a non-existant file

    [src/commands/git_secret_changes.sh, tests/_test_base.bash,
     tests/test_changes.bats]
  [src/commands/git_secret_changes.sh, tests/test_cat.bats]
@joshrabinowitz
Copy link
Collaborator Author

@sobolevn This PR makes git secret changes work correctly with trailing newlines (#291), I think it's close to ready for merging.
Any comments?
Also, can you let me perform the squash-and-merge once you approve so I can edit the commit message (without cutting a new branch or performing a force push).

  [src/commands/git_secret_changes.sh]
@joshrabinowitz joshrabinowitz changed the title tests and comments about 'changes' for #291 Fixes for 'changes' and trailing newlines, for #291 Dec 31, 2018
Copy link
Owner

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but there is still some debug code inside.
👍

p.s. Happy New Year 🌲

src/commands/git_secret_changes.sh Outdated Show resolved Hide resolved
tests/test_changes.bats Outdated Show resolved Hide resolved
tests/test_changes.bats Outdated Show resolved Hide resolved
tests/test_changes.bats Outdated Show resolved Hide resolved
tests/test_changes.bats Outdated Show resolved Hide resolved
tests/test_changes.bats Outdated Show resolved Hide resolved
@joshrabinowitz
Copy link
Collaborator Author

Thanks for the quick review @sobolevn ! And Happy New Year to you as well.

@joshrabinowitz joshrabinowitz merged commit 913d026 into sobolevn:master Jan 1, 2019
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.

None yet

2 participants