semver to only output a version if the git tag for the version and the current commit hash match
This commit is contained in:
parent
7936a986e5
commit
f456c928d7
@ -2,7 +2,7 @@
|
|||||||
current_version = 1.0.5
|
current_version = 1.0.5
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
tag_name = v{new_version}
|
tag_name = {new_version}
|
||||||
message = Bump version: {current_version} -> {new_version}
|
message = Bump version: {current_version} -> {new_version}
|
||||||
|
|
||||||
[bumpversion:file:semver.semver]
|
[bumpversion:file:semver.semver]
|
||||||
|
@ -7,7 +7,7 @@ except ImportError:
|
|||||||
# Python < 3
|
# Python < 3
|
||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
|
|
||||||
version = "1.0.7"
|
version = "1.0.8"
|
||||||
|
|
||||||
|
|
||||||
# Define common exceptions;
|
# Define common exceptions;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import subprocess
|
||||||
try:
|
try:
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -9,6 +10,18 @@ def get_version():
|
|||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config.read('./.bumpversion.cfg')
|
config.read('./.bumpversion.cfg')
|
||||||
version = config.get('bumpversion', 'current_version')
|
version = config.get('bumpversion', 'current_version')
|
||||||
|
# Get the commit hash of the version
|
||||||
|
v_hash = subprocess.Popen(['git', 'rev-list', '-n', '1', version], stdout=subprocess.PIPE,
|
||||||
|
cwd='.').stdout.read().decode('utf-8').rstrip()
|
||||||
|
# Get the current commit hash
|
||||||
|
c_hash = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE,
|
||||||
|
cwd='.').stdout.read().decode('utf-8').rstrip()
|
||||||
|
# If the version commit hash and current commit hash
|
||||||
|
# do not match return the branch name else return the version
|
||||||
|
if v_hash != c_hash:
|
||||||
|
b = subprocess.Popen(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], stdout=subprocess.PIPE,
|
||||||
|
cwd='.').stdout.read().decode('utf-8').rstrip()
|
||||||
|
return b
|
||||||
return version
|
return version
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user