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

Duplicates license in files containing # -*- coding: utf-8 -*- #39

Open
bedge opened this issue Oct 24, 2017 · 2 comments
Open

Duplicates license in files containing # -*- coding: utf-8 -*- #39

bedge opened this issue Oct 24, 2017 · 2 comments
Assignees
Labels

Comments

@bedge
Copy link

bedge commented Oct 24, 2017

Subject says it all.

#!/usr/bin/env python

# Copyright (c) blah

# -*- coding: utf-8 -*-

# Copyright (c) blah

Used:
copyright-header --guess-extension --license-file LICENSE.txt --add-path . --output-dir .

Test case:

%> cat test.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

%> copyright-header --guess-extension --license-file LICENSE.txt --add-path . --output-dir .
SKIP ./LICENSE.txt; excluded
UPDATE ./test.py [output-dir ./.]

%> ls -lrt
total 8
-rw-r--r--+ 1 bedge admin 198 Nov  6 13:09 LICENSE.txt
-rw-r--r--+ 1 bedge admin 463 Nov  6 13:10 test.py

%> cat test.py
#!/usr/bin/env python

# Copyright (c) blah

# -*- coding: UTF-8 -*-

# Copyright (c) blah

@bedge
Copy link
Author

bedge commented Nov 6, 2017

@bedge
Copy link
Author

bedge commented Nov 6, 2017

Was able to work around this by specifying an alternate syntax file:

diff --git a/contrib/syntax.yml b/contrib/syntax.yml
index 8b6cc75..7f99efc 100644
--- a/contrib/syntax.yml
+++ b/contrib/syntax.yml
@@ -39,7 +39,7 @@ perl:
 # vim: set fileencoding=<encoding name> :
 python:
   ext: ['.py']
-  after: ['^#!', '^#.*coding:', '^#.*coding=', '^#.*fileencoding=']
+  after: ['^#!']
   comment:
     open:   '\n'
     close:  '\n'

However, IMO it's a bug as it can inject the license more than once in a source file.

I agree that the original after... line above covers more cases, but it should only insert on the first match.

@osterman osterman added the bug label Dec 12, 2017
@osterman osterman self-assigned this Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants