-
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
4 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
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 @@ | ||
10.0.3 (2a2a8ef572773749b0546af044de5f929b47b241 at 14:00:00 18-10-01 +0200) |
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
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
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,69 @@ | ||
# !/usr/bin/python3 | ||
# coding: utf-8 | ||
|
||
""" Updates version in file with last commit """ | ||
|
||
import os | ||
|
||
from hal.cvs.gits import Repository | ||
|
||
REPO_LOCATION = os.getcwd() | ||
OUTPUT_FILE = os.path.join( | ||
REPO_LOCATION, | ||
"VERSION" | ||
) | ||
|
||
|
||
def get_new_version(version): | ||
return version | ||
|
||
|
||
def read_lines(path): | ||
""" | ||
:param path: str | ||
Path of file | ||
:return: [] of str | ||
Lines in file | ||
""" | ||
|
||
with open(path, "r") as inp: | ||
return inp.readlines() | ||
|
||
|
||
def get_old_version(): | ||
lines = read_lines(OUTPUT_FILE) | ||
raw = lines[0].strip() | ||
return raw | ||
|
||
|
||
def update_version(new_version): | ||
""" | ||
:param new_version: str | ||
Version to write as first line | ||
:return: void | ||
Writes file with new version | ||
""" | ||
|
||
lines = read_lines(OUTPUT_FILE) | ||
lines[0] = new_version | ||
with open(OUTPUT_FILE, "w") as out: | ||
out.writelines(lines) | ||
|
||
|
||
def main(): | ||
print("Parsing", REPO_LOCATION) | ||
|
||
repo = Repository(REPO_LOCATION) | ||
new_version = repo.get_pretty_version(0.001) | ||
old_version = get_old_version() | ||
|
||
print("Old version:", old_version) | ||
print("New version:", new_version) | ||
|
||
new_line = get_new_version(new_version) + "\n" | ||
update_version(new_line) | ||
print("Written to", OUTPUT_FILE) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |