Beispiel #1
0
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
Beispiel #2
0
def compute_version_git_datetime(options):
    from citools.version import get_git_head_tstamp, get_branch_suffix, retrieve_current_branch

    tstamp = int(get_git_head_tstamp())
    if not tstamp:
        raise Exception("Git log parsing error")
    commit_dtime = datetime.fromtimestamp(tstamp)
    commit_version = commit_dtime.strftime("%Y.%m.%d.%H%M")#.split('.')

    dist = _get_distribution()
    branch_suffix = get_branch_suffix(dist.metadata, retrieve_current_branch())

    options.version = commit_version
    dist.metadata.version = commit_version

    dist.metadata.branch_suffix = options.branch_suffix = branch_suffix

    print options.version
 def test_map_obeyed(self):
     dist = Mock()
     dist.branch_rename_map = {'spam' : 'egg'}
     self.assertEquals("egg", get_branch_suffix(dist, "spam"))
 def test_slash_just_dashed(self):
     self.assertEquals("story-123", get_branch_suffix(Mock(spec=[]), "story/123"))