def action_bump(cfg, **kwds): """Bump version number. """ LOGGER.info("Bump version") pos = kwds['pos'] # update both the actual config and its associated template for sec in (cfg['version'], cfg.template()['version']): if pos == 'major': sec['major'] += 1 sec['minor'] = 0 sec['post'] = 0 elif pos == 'minor': sec['minor'] += 1 sec['post'] = 0 elif pos == 'post': sec['post'] += 1 else: # version has been given as 'X.X.X', force it try: version = semver.VersionInfo.parse(pos) sec['major'] = version.major sec['minor'] = version.minor sec['post'] = version.patch except ValueError: LOGGER.error("Bump version: invalid argument '%s'", pos) write_pkg_config(cfg)
def setup(): ensure_created(tmp_dir) init_pkg(tmp_dir) with open(pj(tmp_dir, pkglts_dir, pkg_cfg_file), 'r') as f: cfg = json.load(f) cfg['base'] = dict(pkgname='toto', namespace=None, authors=[('moi', '*****@*****.**')], url=None) env = create_env(cfg) write_pkg_config(env, tmp_dir) regenerate_package(env, tmp_dir)
def action_bump(cfg, **kwds): """Bump version number. """ LOGGER.info("Bump version") pos = kwds['pos'] # update both the actual config and its associated template for sec in (cfg['version'], cfg.template()['version']): if pos == 'major': sec['major'] += 1 sec['minor'] = 0 sec['post'] = 0 elif pos == 'minor': sec['minor'] += 1 sec['post'] = 0 else: sec['post'] += 1 write_pkg_config(cfg)
def tmp_pths(): pth = 'toto_mg_rg' ensure_created(pth) init_pkg(pth) with open(pj(pth, pkglts_dir, pkg_cfg_file), 'r') as f: pkg_cfg = json.load(f) pkg_cfg['base'] = dict(pkgname='toto', namespace=None, authors=[('moi', '*****@*****.**')], namespace_method="pkg_util", url=None) cfg = Config(pkg_cfg) write_pkg_config(cfg, pth) regenerate_package(cfg, pth) init_file = pj(pth, "src", "toto", "__init__.py") yield pth, init_file rmdir(pth)
def test_pkg_cfg_read_write_maintains_templates(tmp_dir): pkg_cfg = dict(DEFAULT_CFG) pkg_cfg['base'] = dict(pkgname="toto", namespace="nm", url=None, authors=[("moi", "moi@aussi")]) pkg_cfg['license'] = dict(name="CeCILL-C", organization="org", project="{{ base.pkgname }}", year="2015") json.dump(pkg_cfg, open(pj(tmp_dir, ".pkglts/pkg_cfg.json"), 'w')) cfg = get_pkg_config(tmp_dir) assert cfg['license']['project'] == "toto" write_pkg_config(cfg, tmp_dir) pkg_cfg = json.load(open(pj(tmp_dir, ".pkglts/pkg_cfg.json"))) pkg_cfg["base"]["pkgname"] = "tutu" json.dump(pkg_cfg, open(pj(tmp_dir, ".pkglts/pkg_cfg.json"), 'w')) cfg = get_pkg_config(tmp_dir) assert cfg['license']['project'] == "tutu"
def tmp_pths(): pth = Path('toto_mg_rg') ensure_created(pth) init_pkg(pth) with open((pth / pkglts_dir / pkg_cfg_file), 'r') as fhr: pkg_cfg = json.load(fhr) pkg_cfg['base'] = dict(pkgname='toto', namespace=None, authors=[('moi', '*****@*****.**')], url=None) pkg_cfg['src'] = dict(namespace_method="pkg_util") cfg = Config(pkg_cfg) write_pkg_config(cfg, pth) regenerate_package(cfg, pth) init_file = pth / "src/toto/__init__.py" yield pth, init_file rmdir(pth)
def test_pkg_cfg_read_write_maintains_templates(): cfg = dict(default_cfg) cfg['base'] = dict(pkgname="toto", namespace="nm", url=None, authors=[("moi", "moi@aussi")]) cfg['license'] = dict(name="CeCILL-C", organization="org", project="{{ base.pkgname }}", year="2015") with open(pj(tmp_dir, ".pkglts/pkg_cfg.json"), 'w') as f: json.dump(cfg, f) env = get_pkg_config(tmp_dir) assert env.globals['license'].project == "toto" write_pkg_config(env, tmp_dir) with open(pj(tmp_dir, ".pkglts/pkg_cfg.json"), 'r') as f: cfg = json.load(f) cfg["base"]["pkgname"] = "tutu" with open(pj(tmp_dir, ".pkglts/pkg_cfg.json"), 'w') as f: json.dump(cfg, f) env = get_pkg_config(tmp_dir) assert env.globals['license'].project == "tutu"