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 #852 optionally add last newline #902

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kylos101
Copy link

@kylos101 kylos101 commented Nov 7, 2021

Description

Fixes #852

Motivation and Context

  • I have raised an issue to propose this change (required)

How Has This Been Tested?

So far, just manually, but will write unit tests after getting feedback on the fix.
Tested using the stack.yml file in this repo, ran iterations where it did not have trailing new lines, and did - both behave the same now.

Testing was done on Ubuntu; no Windows testing has been done yet.

I intentionally do this check early, in the same block as the other append checks, so that if we encounter an error while trying to fix the trailing new lines, we do not leave behind a handler folder.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s (no, but I will, I look forward to Derek telling me abou tthis) 👍
  • I have added tests to cover my changes. (not yet, I plan to, but first want to get feedback on my fix) 👍
  • All new and existing tests passed.

@derek derek bot added the new-contributor label Nov 7, 2021
@derek
Copy link

derek bot commented Nov 7, 2021

Thank you for your contribution. unfortunately, one or more of your commits are missing the required "Signed-off-by:" statement. Signing off is part of the Developer Certificate of Origin (DCO) which is used by this project.

Read the DCO and project contributing guide carefully, and amend your commits using the git CLI. Note that this does not require any cryptography, keys or special steps to be taken.

💡 Shall we fix this?

This will only take a few moments.

First, clone your fork and checkout this branch using the git CLI.

Next, set up your real name and email address:

git config --global user.name "Your Full Name"
git config --global user.email "[email protected]"

Finally, run one of these commands to add the "Signed-off-by" line to your commits.

If you only have one commit so far then run: git commit --amend --signoff and then git push --force.
If you have multiple commits, watch this video.

Check that the message has been added properly by running "git log".

@kylos101
Copy link
Author

kylos101 commented Nov 7, 2021

@alexellis take a peek and let me know what you think? Once I have your 👍 on the fix itself, I'll proceed with unit tests. Thanks!

commands/new_function.go Outdated Show resolved Hide resolved
Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

I didn't realise this would be as complicated as it's turned out. I'm leaving some comments.

commands/new_function.go Outdated Show resolved Hide resolved
commands/new_function.go Outdated Show resolved Hide resolved
@kylos101
Copy link
Author

kylos101 commented Nov 21, 2021

Hi @alexellis this should ready for review now (no rush, just whenever you get a chance).

FYI, while testing I found this issue #906 , let me know if you'd like me to draft a fix in a separate PR?

alexellis
alexellis previously approved these changes Dec 7, 2021
Copy link
Member

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

Approved

@@ -423,3 +428,58 @@ func Test_getPrefixValue_Flag(t *testing.T) {
t.Errorf("want %s, got %s", want, val)
}
}

func Test_addEofNewlines_works(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this getting tested?

I'd expect something like if wantedYAML == os.ReadFile("stack.yml")

Copy link
Author

Choose a reason for hiding this comment

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

Nice catch, I just added this. Let me know if anything else is needed?

Tested with Linux and Windows, by appending many new functions to
a single stack.yml file.

Signed-off-by: Kyle Brennan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Append flag doesnt add newline if not present in file
2 participants