-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
297 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- id: poetry-export | ||
name: poetry export | ||
description: pre-commit hook to keep requirements.txt updated | ||
entry: poetry-export | ||
language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# pre-commit-poetry-export | ||
Pre-commit hook to keep requirements.txt updated | ||
pre-commit hook to keep requirements.txt updated | ||
|
||
- [] write readme | ||
- [] test |
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = '0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import hashlib | ||
import os | ||
|
||
|
||
def main(argv=None): | ||
os.system('cp requirements.txt old.requirements.txt') | ||
os.system('poetry export -f requirements.txt > requirements.txt') | ||
|
||
with open('requirements.txt', 'r') as new,\ | ||
open('old.requirements.txt', 'r') as old: | ||
new_content = new.read() | ||
new.close() | ||
new_md5 = hashlib.md5() | ||
new_md5.update(new_content.encode('utf-8')) | ||
|
||
old_content = old.read() | ||
old.close() | ||
old_md5 = hashlib.md5() | ||
old_md5.update(old_content.encode('utf-8')) | ||
|
||
if new_md5.hexdigest() == old_md5.hexdigest(): | ||
os.system('rm old.requirements.txt') | ||
return 0 | ||
|
||
print('requirements.txt updated!') | ||
return 1 | ||
|
||
|
||
if __name__ == '__name__': | ||
exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[tool.poetry] | ||
name = "pre-commit-poetry-export" | ||
version = "0.1.1" | ||
description = "pre-commit hook to keep requirements.txt updated" | ||
authors = ["Antonio Luckwu <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
homepage = "https://github.com/avlm/pre-commit-poetry-export" | ||
repository = "https://github.com/avlm/pre-commit-poetry-export" | ||
keywords = ["pre-commit", "hook", "poetry", "export", "pip", "requirements", "requirements.txt"] | ||
classifiers = [ | ||
"Environment :: Console", | ||
"Operating System :: OS Independent", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
include = [ | ||
"LICENSE", | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^5.2" | ||
flake8 = "^3.8.3" | ||
|
||
[tool.poetry.scripts] | ||
poetry-export = 'pre_commit_poetry_export.poetry_export:main' | ||
|
||
[build-system] | ||
requires = ["poetry>=0.12"] | ||
build-backend = "poetry.masonry.api" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from pre_commit_poetry_export import __version__ | ||
|
||
|
||
def test_version(): | ||
assert __version__ == '0.1.0' |