Add borgmatic --version command-line flag to get the current installed version number.
the build was successful Details

This commit is contained in:
Dan Helfman 2018-12-25 21:01:08 -08:00
parent 426f54c9cc
commit fd46efb193
5 changed files with 25 additions and 10 deletions

3
NEWS
View File

@ -1,8 +1,9 @@
1.2.14.dev0
1.2.14
* #103: When generating sample configuration with generate-borgmatic-config, document the defaults
for each option.
* #116: When running multiple configuration files, attempt all configuration files even if one of
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
* #100: Support for --stats command-line flag independent of --verbosity.

View File

@ -5,6 +5,8 @@ import os
from subprocess import CalledProcessError
import sys
import pkg_resources
from borgmatic.borg import (
check as borg_check,
create as borg_create,
@ -136,6 +138,13 @@ def parse_arguments(*arguments):
default=0,
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)
@ -346,6 +355,10 @@ def main(): # pragma: no cover
args = parse_arguments(*sys.argv[1:])
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))
logger.debug('Ensuring legacy configuration is upgraded')
convert.guard_configuration_upgraded(LEGACY_CONFIG_PATH, config_filenames)

View File

@ -1,7 +1,7 @@
from setuptools import setup, find_packages
VERSION = '1.2.14.dev0'
VERSION = '1.2.14'
setup(

View File

@ -1,3 +1,5 @@
import subprocess
from flexmock import flexmock
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():
with pytest.raises(ValueError):
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

View File

@ -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