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

insert-license should not add a LF at the end of the license header file if it does not have one, to prevent an ugly empty separator line #70

Closed
vorburger opened this issue Mar 11, 2023 · 2 comments · Fixed by #73

Comments

@vorburger
Copy link
Contributor

Salut! I ❤️ LOVE insert-license - this is GREAT! I just have 1 very small gripe with... 😃 I wish it wouldn't insert a new line! Details:

  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.4.2
    hooks:
      - id: insert-license
        files: \.java$
        args:
          - --comment-style
          - /*| *| */
          - --license-filepath
          - LICENSE-header.txt
          - --fuzzy-match-generates-todo
          - --use-current-year

That LICENSE-header.txt file DOES NOT end with a LF (e.g. perl -p -i -e 'chomp if eof' LICENSE-header.txt; and I've double-checked with hexedit that the last byte is not a 0A (LF), but a 2E for .). The *.java files which do not contain a license header will be updated to like this by insert-license:

...

 * limitations under the License.
 */

package dev.enola.k8s;

The empty line after */ before package bothers me (yeah, I know, hair splitting; sorry!) - and seems to be added by insert-license? Would it be possible to avoid it doing that, if the given file does not end in a newline?

I'm currently working around this by removing that separator line (and that's kept and not put back), but I wish it wouldn't add it in the first place...

Thank You again for insert-license!

@vorburger
Copy link
Contributor Author

Staring at the source code, I've just noticed that there is an --no-extra-eol... I'll try that out - and contrib a PR to update the README doc!

@Lucas-C
Copy link
Owner

Lucas-C commented Mar 12, 2023

Staring at the source code, I've just noticed that there is an --no-extra-eol... I'll try that out - and contrib a PR to update the README doc!

Yes, --no-extra-eol should be the solution!

A PR to update the README.md would be welcome for sure 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants