Skip to content

Commit

Permalink
Version 1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Oct 3, 2019
1 parent 882483d commit 4b27b97
Show file tree
Hide file tree
Showing 9 changed files with 1,143 additions and 646 deletions.
26 changes: 14 additions & 12 deletions .travis.yml
@@ -1,21 +1,23 @@
dist: xenial
language: python

matrix:
fast_finish: true
include:
- python: 2.7
- python: 3.6
- python: 3.7
dist: xenial
sudo: true
python:
- 3.6
- 3.7

install:
- pip install poetry
- poetry install
- poetry develop
before_install:
- pip freeze | xargs pip uninstall -y
- curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
- source "$HOME/.poetry/env"

install: poetry install

script:
- poetry run flake8 .
- poetry run pytest
- poetry check
- poetry run pip check
- poetry run safety check --bare --full-report

after_success:
- pip install coveralls
Expand Down
20 changes: 16 additions & 4 deletions CHANGELOG.md
@@ -1,16 +1,28 @@
# Version 0.2.0
# Version history

## Features
We follow Semantic Versions since the `0.1.0` release.


## Version 1.0.0

### Features

- **Breaking**: dropped python2 support, now we support python3.6+


## Version 0.2.0

### Features

- Adds optional param `short` which returns shorter commit hash

## Misc
### Misc

- Adds `poetry` as the main project tool
- Removed `setup.py`
- `README.rst` converted to `README.md`
- Python 3.7 is now supported

## Version 0.1.0
### Version 0.1.0

- Initial release
26 changes: 13 additions & 13 deletions jinja2_git.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

import subprocess
import subprocess # noqa: S404

from jinja2 import nodes
from jinja2.ext import Extension
Expand All @@ -11,15 +11,6 @@ class GitExtension(Extension):

tags = {'gitcommit'}

def _commit_hash(self, short):
params = ['git', 'rev-parse', 'HEAD']

if short:
params.insert(2, '--short')

output = subprocess.check_output(params)
return output.decode('utf-8').strip()

def parse(self, parser):
"""Main method to render data into the template."""
lineno = next(parser.stream).lineno
Expand All @@ -28,7 +19,16 @@ def parse(self, parser):
parser.stream.skip(1)
short = parser.parse_expression()
else:
short = nodes.Const(False)
short = nodes.Const(False) # noqa: WPS425

result = self.call_method('_commit_hash', [short], [], lineno=lineno)
return nodes.Output([result], lineno=lineno)
commit = self.call_method('_commit_hash', [short], [], lineno=lineno)
return nodes.Output([commit], lineno=lineno)

def _commit_hash(self, short):
command = ['git', 'rev-parse', 'HEAD']

if short:
command.insert(2, '--short')

output = subprocess.check_output(command) # noqa: S603
return output.decode('utf-8').strip()

0 comments on commit 4b27b97

Please sign in to comment.