Ejemplo n.º 1
0
def branches():
    """
    show branches of local repository
    do not used, for debug purposes only
    :return:
    """
    result = []
    for h in logic.get_repository().heads:
        result.append(h.name)
    return json.dumps(result)
Ejemplo n.º 2
0
def commits():
    """
    show commits of specified branch
    do not used, for debug purposes only
    :return:
    """
    result = []
    repo = logic.get_repository()
    branch = int(request.args.get('branch'))
    commit = repo.heads[branch].commit
    for i in range(commit.count()):
        result.append(commit.name_rev)
        if len(commit.parents):
            commit = commit.parents[0]
    return json.dumps(result)
Ejemplo n.º 3
0
def index():
    repo = logic.get_repository()
    # let's read registry index for "outdated" marks
    built = []
    config = current_app.config['CADENCE']
    with Path(config.bundle.registry).open(mode='r') as index_file:
        props = json.load(index_file)
        for pack in props['packages']:
            built.append(pack['version'])
    print(built)
    branches = {}
    tags = {}
    for tag in repo.tags:
        tags[tag.commit.hexsha] = tag.name

    for branch in repo.remotes.origin.refs:
        outdated = True
        commit = branch.commit
        commits = []
        while commit:
            if commit.hexsha in tags:
                commits.append(dict(
                    version     = commit.hexsha,
                    tag         = tags[commit.hexsha],
                    author      = commit.author.name,
                    modified    = datetime.fromtimestamp(commit.authored_date).strftime('%Y-%m-%d %H:%M:%S'),
                    changes     = commit.message,
                ))
                version = commit.hexsha
            if len(commit.parents):
                commit = commit.parents[0]
            else:
                commit = False
            # if last commit in built, then branch is not outdated
            if not commit and version in built:
                outdated = False

        branch_name = branch.name.lstrip('origin/')
        if 'HEAD' != branch_name:
            branches[branch_name] = dict(commits = commits.copy(), outdated = outdated)
    # print(branches)
    return render_template("index.html", branches = branches)