def get_new_dependencies(dir, accepted_tag_pattern=None): cfile = ControlFile(filename=os.path.join(dir, 'debian', 'control')) packages = cfile.get_packages() version = ".".join(map(str, compute_version(get_git_describe(repository_directory=dir, fix_environment=True, accepted_tag_pattern=accepted_tag_pattern)))) for p in packages: p.version = version return packages
def test_higher_version_preferred_even_when_tag_is_on_top_of_the_tree(self): """ As previous test, but some git versions change their output when tagged version is also HEAD """ try: self.prepare(tag_latest_version=True) self.assertEquals((1, 3, 0), compute_version( get_git_describe(repository_directory=self.repo, fix_environment=True, accepted_tag_pattern='repo-*') )) finally: rmtree(self.repo) os.chdir(self.oldcwd)
def get_package_path(package_name, module_name, current_version=None): """ Return filesystem path to debian package build by bdist_deb""" if not current_version: #FIXME: not to hardcode format = "%s-[0-9]*" % module_name current_version = '.'.join(map(str, compute_version(get_git_describe(accepted_tag_pattern=format)))) package_name = u"%(name)s_%(version)s_%(arch)s.deb" % { 'name' : package_name, 'version' : current_version, 'arch' : 'all' } return os.path.normpath(os.path.join(os.curdir, os.pardir, package_name))
def compute_version_git(options): from citools.version import get_git_describe, compute_version if not getattr(options, "accepted_tag_pattern", None): options.accepted_tag_pattern = "%s-[0-9]*" % options.name current_git_version = get_git_describe(accepted_tag_pattern=options.accepted_tag_pattern) options.version = compute_version(current_git_version) options.version_str = '.'.join(map(str, options.version)) print options.version_str
def test_higher_version_always_preferred(self): """ Check we're retrieving "higher" version, meaning number of tags since higher version tag, unlike git describe which is prefferring tag that has lower number of commits to current HEAD. """ try: self.prepare() self.assertEquals((1, 2, 4), compute_version( get_git_describe(repository_directory=self.repo, fix_environment=True, accepted_tag_pattern='repo-*') )) finally: rmtree(self.repo) os.chdir(self.oldcwd)
def _check_filtering_works(self, tag, retag, search_pattern, expected_result_start): self.prepare_tagged_repo_with_file(tag=tag) # create a commit f = open(os.path.join(self.repo, 'test.txt'), 'wb') f.write("test test") f.close() check_call(['git', 'add', '*']) check_call(['git', 'commit', '-a', '-m', '"dummy"'], stdout=PIPE) check_call(['git', 'tag', '-m', '"tagging"', '-a', retag]) describe = get_git_describe(accepted_tag_pattern=search_pattern) self.assertTrue(describe.startswith(expected_result_start), "Retrieved bad describe %s" % describe)
def compute_version_git(options): from citools.version import get_git_describe, compute_version, get_branch_suffix, retrieve_current_branch if not getattr(options, "accepted_tag_pattern", None): options.accepted_tag_pattern = "%s-[0-9]*" % options.name dist = _get_distribution() current_git_version = get_git_describe(accepted_tag_pattern=options.accepted_tag_pattern) branch_suffix = get_branch_suffix(dist.metadata, retrieve_current_branch()) options.version = compute_version(current_git_version) dist.metadata.version = options.version_str = '.'.join(map(str, options.version)) dist.metadata.branch_suffix = options.branch_suffix = branch_suffix print options.version_str
def test_number_of_commit_since_tag(self): self.prepare_tagged_repo_with_file(tag='0.1-lol') # create a commit f = open(os.path.join(self.repo, 'test.txt'), 'wb') f.write("test test") f.close() proc = Popen(['git', 'add', '*']) proc.wait() self.assertEquals(0, proc.returncode) proc = Popen(['git', 'commit', '-a', '-m', '"dummy"'], stdout=PIPE, stdin=PIPE) proc.wait() self.assertEquals(0, proc.returncode) self.assertTrue(get_git_describe().startswith('0.1-lol-1'))
def get_new_dependencies(dir, accepted_tag_pattern=None, branch="master"): version = compute_version(get_git_describe(repository_directory=dir, fix_environment=True, accepted_tag_pattern=accepted_tag_pattern)) control = os.path.join(dir, 'debian', 'control') version = ".".join(map(str, version)) ### FIXME: We shall not do this again AND should only use templates from citools.build import replace_template_files replace_template_files(root_directory=dir, variables={ 'branch' : branch, 'version' : version, }) cfile = ControlFile(filename=control) packages = cfile.get_packages() for p in packages: p.version = version return packages
def bump(): """ Bump most-minor tagged version. Assumes git. Bump is completed only since last release. This is assumed to have $projectname-[digit]* format. If not, it shall be configured as options.release_tag_format. """ if getattr(options, "release_tag_format", False): format = release_tag_format else: format = "%s-[0-9]*" % options.name from citools.version import get_git_describe, compute_version version = compute_version(get_git_describe(accepted_tag_pattern=format)) new_version = list(version[:-1]) new_version[len(new_version)-1] += 1 tag = options.name + "-" + ".".join(map(str, new_version)) sh('git tag -a %s -m "paver bump to version %s"' % (tag, tag))
def test_fetched_repository_has_same_version(self): dir = mkdtemp() repodir = fetch_repository(repository=self.repo_two, workdir=dir) self.assertEquals((2, 0, 12), compute_version(get_git_describe(repository_directory=repodir, fix_environment=True))) rmtree(dir)
def test_proper_second_child_version(self): self.assertEquals((2, 0, 12), compute_version(get_git_describe(repository_directory=self.repo_two, fix_environment=True)))
def test_proper_child_version(self): self.assertEquals((1, 0, 59, 1), compute_version(get_git_describe(repository_directory=self.repo_one, fix_environment=True)))
def test_pattern_used_to_filter_everything_acting_like_without_tag(self): self.prepare_tagged_repo_with_file(tag='0.1-lol') self.assertEquals('0.0', get_git_describe(accepted_tag_pattern='myproject-*'))
def test_tag_retrieved(self): self.prepare_tagged_repo_with_file(tag='0.1-lol') self.assertEquals('0.1-lol', get_git_describe())
def test_without_tag(self): self.assertEquals('0.0', get_git_describe())