Add borgmatic --version command-line flag to get the current installed version number.
This commit is contained in:
parent
426f54c9cc
commit
fd46efb193
5 changed files with 25 additions and 10 deletions
3
NEWS
3
NEWS
|
@ -1,8 +1,9 @@
|
||||||
1.2.14.dev0
|
1.2.14
|
||||||
* #103: When generating sample configuration with generate-borgmatic-config, document the defaults
|
* #103: When generating sample configuration with generate-borgmatic-config, document the defaults
|
||||||
for each option.
|
for each option.
|
||||||
* #116: When running multiple configuration files, attempt all configuration files even if one of
|
* #116: When running multiple configuration files, attempt all configuration files even if one of
|
||||||
them errors. Log a summary of results at the end.
|
them errors. Log a summary of results at the end.
|
||||||
|
* Add borgmatic --version command-line flag to get the current installed version number.
|
||||||
|
|
||||||
1.2.13
|
1.2.13
|
||||||
* #100: Support for --stats command-line flag independent of --verbosity.
|
* #100: Support for --stats command-line flag independent of --verbosity.
|
||||||
|
|
|
@ -5,6 +5,8 @@ import os
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from borgmatic.borg import (
|
from borgmatic.borg import (
|
||||||
check as borg_check,
|
check as borg_check,
|
||||||
create as borg_create,
|
create as borg_create,
|
||||||
|
@ -136,6 +138,13 @@ def parse_arguments(*arguments):
|
||||||
default=0,
|
default=0,
|
||||||
help='Display verbose progress (1 for some, 2 for lots)',
|
help='Display verbose progress (1 for some, 2 for lots)',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--version',
|
||||||
|
dest='version',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help='Display installed version number of borgmatic and exit',
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args(arguments)
|
args = parser.parse_args(arguments)
|
||||||
|
|
||||||
|
@ -346,6 +355,10 @@ def main(): # pragma: no cover
|
||||||
args = parse_arguments(*sys.argv[1:])
|
args = parse_arguments(*sys.argv[1:])
|
||||||
logging.basicConfig(level=verbosity_to_log_level(args.verbosity), format='%(message)s')
|
logging.basicConfig(level=verbosity_to_log_level(args.verbosity), format='%(message)s')
|
||||||
|
|
||||||
|
if args.version:
|
||||||
|
print(pkg_resources.require('borgmatic')[0].version)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
config_filenames = tuple(collect.collect_config_filenames(args.config_paths))
|
config_filenames = tuple(collect.collect_config_filenames(args.config_paths))
|
||||||
logger.debug('Ensuring legacy configuration is upgraded')
|
logger.debug('Ensuring legacy configuration is upgraded')
|
||||||
convert.guard_configuration_upgraded(LEGACY_CONFIG_PATH, config_filenames)
|
convert.guard_configuration_upgraded(LEGACY_CONFIG_PATH, config_filenames)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,7 +1,7 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
VERSION = '1.2.14.dev0'
|
VERSION = '1.2.14'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from flexmock import flexmock
|
from flexmock import flexmock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -169,3 +171,10 @@ def test_parse_arguments_disallows_json_without_list_or_info():
|
||||||
def test_parse_arguments_disallows_json_with_both_list_and_info():
|
def test_parse_arguments_disallows_json_with_both_list_and_info():
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
module.parse_arguments('--list', '--info', '--json')
|
module.parse_arguments('--list', '--info', '--json')
|
||||||
|
|
||||||
|
|
||||||
|
def test_borgmatic_version_matches_news_version():
|
||||||
|
borgmatic_version = subprocess.check_output(('borgmatic', '--version')).decode('ascii')
|
||||||
|
news_version = open('NEWS').readline()
|
||||||
|
|
||||||
|
assert borgmatic_version == news_version
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
def test_setup_version_matches_news_version():
|
|
||||||
setup_version = subprocess.check_output(('python', 'setup.py', '--version')).decode('ascii')
|
|
||||||
news_version = open('NEWS').readline()
|
|
||||||
|
|
||||||
assert setup_version == news_version
|
|
Loading…
Reference in a new issue