Skip to content

Commit

Permalink
Release 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rdipardo committed Apr 4, 2021
1 parent 231db22 commit c7cceae
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.vader linguist-language=Vim
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/new-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ assignees: ''
*Please provide the following with your description of the issue:*
- [ ] Platform information (e.g. Ubuntu Linux 16.04):
- [ ] Python version:
- [ ] plugin version (enter `:echo g:cpywrite#version` at the vim command window):
- [ ] Plugin version (`vim -V1 -i NONE -ENsu ~/.vimrc -c ':echo g:cpywrite#version' +q`):

*If applicable, include one of the following:*
- [ ] Output of `pip list | grep requests`:
Expand Down
Binary file removed .github/img/vim_8.2.2549.gif
Binary file not shown.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ jobs:
version: ${{ matrix.nvim-version }}

- name: Run python tests
run: pytest -v
# > platform linux -- Python 3.7.3, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
# > ...
# > /usr/lib/python3/dist-packages/socks.py:58: DeprecationWarning: Using or importing the ABCs from 'collections'
# > instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
# > from collections import Callable
run: pytest -v -W ignore::DeprecationWarning

- name: Test plugin on vim
run: |
Expand Down
20 changes: 18 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ CHANGELOG
:depth: 1
:backlinks: top

0.3.4
======
**(2021-04-04)**

Fixed
-----
- prevent copyright year regex from accidentally matching older versions of the
Mozilla Public License
- don't throw an exception if the full name of a license doesn't start with *The*
- don't print angle brackets when ``user.email`` is empty

Changed
-------
- try to detect the user's interpreter program when modifying a shell script
- remove example GIF from plugin assets and use a hyperlink instead

0.3.3
======
**(2021-03-08)**
Expand All @@ -14,7 +30,7 @@ Fixed
-----
- (temporarily) request *ALL* full text licenses from the `previous release versions`_
(with the exception of the `Unlicense`_ and `BSD-1-Clause`_ as before). A future
release will probably start using a different repository when theses versions
release will probably start using a different repository when these versions
fall too far behind the officially recognized templates
- minor refactoring of some redundant code

Expand All @@ -32,7 +48,7 @@ Fixed
`BSD-1-Clause`_
- minor pruning of some unreachable code (overlooked in `last release`_)

.. _last release: https://github.com/rdipardo/vim-cpywrite/releases/tag/v0.3.1
.. _last release: https://github.com/rdipardo/vim-cpywrite/blob/master/CHANGELOG.rst#031

Added
-----
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vim-cpywrite

Generate copyright headers for any open source license

.. figure:: .github/img/vim_8.2.2549.gif
.. figure:: https://raw.githubusercontent.com/rdipardo/vim-cpywrite/media/rel/vim_8.2.2549.gif
:alt: vim-win-x64-demo
:align: center
:width: 900
Expand Down
2 changes: 1 addition & 1 deletion plugin/cpywrite.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if get(g:, 'loaded_cpywrite') | finish | endif
let g:loaded_cpywrite = 1

let g:cpywrite#version = '0.3.3'
let g:cpywrite#version = '0.3.4'

if empty(get(g:, 'cpywrite#default_license', ''))
let g:cpywrite#default_license = 'GPL-3.0-or-later'
Expand Down
2 changes: 1 addition & 1 deletion rplugin/pythonx/cpywrite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
~~~~~~~~~
"""

__version__ = '0.3.3'
__version__ = '0.3.4'
__authors__ = ['Robert Di Pardo']
__url__ = 'https://github.com/rdipardo/vim-cpywrite'
__license__ = 'MIT'
Expand Down
27 changes: 18 additions & 9 deletions rplugin/pythonx/cpywrite/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _close_block_comment(dest):
print('\n?>', file=dest)

def _apply_format(text, pattern, author, email, year):
authorship = year + ' ' + author + ' <' + email + '>'
authorship = year + ' ' + author

# watch out for 20^th-century year template of the older GPLs
text = \
Expand All @@ -70,12 +70,13 @@ def _apply_format(text, pattern, author, email, year):
re.sub(r'(%s).+(\w+Permission)' % self.tokens[1],
'%sPermission' % self.tokens[1], text))
# wrap text if raw header has no break after author's email
if self.rights.spdx_code.startswith('ECL'):
run_on_text = re.search(r'(%s).+((%s)|\<(%s)\>)\w' \
elif self.rights.spdx_code.startswith('ECL'):
run_on_text = re.search(r'(%s).+((%s)|(%s))\w' \
% (self.tokens[1],
author,
re.escape(email)),
text)

if run_on_text:
one_liner = \
'Copyright (c) ' + authorship + ' Distributed under the'
Expand All @@ -88,21 +89,26 @@ def _apply_format(text, pattern, author, email, year):
self.tokens[1],
run_on_text.group()[-1]),
text)
else:
text = re.sub(r'(%s)' % re.escape(authorship),
authorship + email,
text)

return text

try:
out = StringIO()
year = str(datetime.now())[:4]
author, email = _get_source_author()
contact = ' <' + email + '>' if email else ''
copying = \
'Copyright (c) ' + year + ' ' + author + ' <' + email + '>'
'Copyright (c) ' + year + ' ' + author + contact
terms = \
self.rights.header \
if not full_text \
else self.rights.license_text
author_date = \
re.compile(r"(?!.*(http).*)[\<\[\s][YEARX]+[\>\]\s].+[\>\]]",
re.compile(r"(?!.*(http).*)[\<\[\s]((YEAR)|[YX]+)[\>\]\s].+[\>\]]",
re.IGNORECASE)

if self.lang_key in _SCRIPT_HEADERS:
Expand All @@ -128,12 +134,12 @@ def _clean_tokens(tkn, line):
# probably a GFDL or older GPL with an oddball authorship
# template
author_date = \
re.compile(r"(?!.*(http).*)[\<\[\s][YEARX]+[\>\]\s].+[\>\]\.]",
re.compile(r"(?!.*(http).*)[\<\[\s]((YEAR)|[YX]+)[\>\]\s].+[\>\]\.]",
re.IGNORECASE)

terms = _apply_format(terms, author_date, author, email, year)
terms = _apply_format(terms, author_date, author, contact, year)

if not re.findall(r'(<%s>)' % re.escape(email),
if not re.findall(r'(%s)' % author,
terms,
re.MULTILINE) \
and not in_pub_domain(self.rights.spdx_code):
Expand Down Expand Up @@ -373,7 +379,10 @@ def _get_source_author():
"""

_SCRIPT_HEADERS = {
'shell script': '#!/usr/bin/env bash',
'shell script': '#!/usr/bin/env %s'
% re.sub(r'^\$\w+',
'bash',
path.expandvars('$SHELL').split('/')[-1]),
'perl': '#!/usr/bin/env perl',
'php': '<?php',
'python': '#!/usr/bin/env python%s\n# -*- coding: utf-8 -*-\n'
Expand Down
7 changes: 4 additions & 3 deletions rplugin/pythonx/cpywrite/spdx/license.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ def __str__(self):
name = search(r'.+[lL]icense', name)
version = search(r'\d\.\d.*$', self.license_name)

return (template % name.group()) + \
(' Version ' + version.group() if version else '') + \
'.'
if name:
return (template % name.group()) + \
(' Version ' + version.group() if version else '') + \
'.'

if self.spdx_code:
return (template % self.spdx_code) + \
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.3
0.3.4

0 comments on commit c7cceae

Please sign in to comment.