Last active
February 11, 2020 11:10
-
-
Save nebil/b4c469580f2667762a3adda97adb4d9a to your computer and use it in GitHub Desktop.
📦 releasetype -- a function to get the release type of a version
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
""" | |
releasetype.py -- a function to get the release type of a version | |
This source code is licensed under a Creative Commons CC0 license. | |
More info at <https://creativecommons.org/publicdomain/zero/1.0/>. | |
""" | |
def get_release_type(version): | |
""" | |
>>> get_release_type('3.1.4') | |
'patch' | |
>>> get_release_type('4.2.0') | |
'minor' | |
>>> get_release_type('5.0.0') | |
'major' | |
""" | |
# NOTE: I think this is an elegant implementation. | |
major, minor, patch = map(int, version.split(".")) | |
if patch: return "patch" | |
if minor: return "minor" | |
if major: return "major" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment