Skip to content

Commit

Permalink
autolabel git versions, closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
ModischFabrications committed Apr 24, 2020
1 parent fa95144 commit 4222d8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,24 @@ repos:

#bandit, vulture?

# pre push git version tagging

- repo: local
hooks:
- id: git_tag
name: tag git version
description: tag git version if it's outdated
pass_filenames: false
# verbose: true
entry: python tag_from_version.py
language: system
# git version check only needed if version could have changed
files: main.py
types: [python]
stages: [push]

- id: tests
name: run tests
description: Run pytest
# don't run for every file, always full execution (with default filters to skip untestable files)
pass_filenames: false
entry: python -m pytest
language: system
Expand Down
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from app.solver.data.Result import Result
from app.solver.solver import distribute

version = "v0.4.6"
version = "v0.4.8"

app = FastAPI(
title="CutSolverBackend",
Expand Down
12 changes: 6 additions & 6 deletions tag_from_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ def process():
assert not repo.bare

version = main.version
print(f"code version: {version}")
newest_tag = repo.tags[-1]
newest_git_version = newest_tag.name
print(f"git version: {newest_git_version}")
print(f"code version: {version}, git version: {newest_git_version}")

if newest_git_version == version:
print("Everything up to date, job done")
return 0

if newest_git_version > version:
print("You updated git without updating the code version!", file=stderr)
print("Git was updated without updating the code version!", file=stderr)
# TODO: edit code (this is very dangerous!)
return 1

if newest_git_version < version:
print("git version outdated, updating with newest tag")
# FIXME: tag with new version
# repo.create_tag()
print("git tag outdated, updating with newest version")
# this could technically go back in history until the version change happened,
# but as long as nothing was pushed we can skip local only versions.
repo.create_tag(version, message=f"autobump version from {newest_git_version} to {version}")


if __name__ == '__main__':
Expand Down

0 comments on commit 4222d8b

Please sign in to comment.