Exemplo n.º 1
0
def __upload(proj, repo, branch, data, maker, force=True):
    root, source, dist = (None, None, None)
    try:
        root = Folder(data.root or '~')
        source = root.child_folder('src')
        source.make()
        source = source.child_folder(proj)
        dist = root.child_folder('dist')
        tree = Tree(source, repo=repo, branch=branch)
        key = None
        if not force:
            key = check_revision_already_published(proj, data.bucket, tree)

        if not key:
            b = Bucket(data.bucket)
            b.make()
            key_folder = Folder(proj).child_folder(branch)
            zippath = dist.child_file(proj + '.zip')
            tree.clone(tip_only=True)
            sha = tree.get_revision(short=False)
            key_folder = key_folder.child_folder(sha)
            target = dist.child_folder(proj)
            target.make()
            maker(source, target)
            target.zip(zippath.path)
            b.add_file(zippath, target_folder=key_folder.path)
            key = b.bucket.get_key(key_folder.child(zippath.name))
    finally:
        if source:
            source.delete()
        if dist:
            dist.delete()

    return key.generate_url(30000)
Exemplo n.º 2
0
def test_fetch_ref():
    new_css = 'body { background-color: white; }'
    new_branch = 'new_css'
    local_repo1.new_branch(new_branch)
    revision = None
    with local_repo1.branch(new_branch):
        File(GIT_TEST_DIR1.child(CSS_FILE)).write(new_css)
        local_repo1.commit('Changed background-color')
        local_repo1.push()

        revision = local_repo1.get_revision(short=False)
        modified = local_repo1.get_last_committed()
        local_repo1.make_ref('refs/test/testref', revision)
        local_repo1.push(ref='refs/test/testref')
    GIT_TEST_DIR2.delete()
    local_repo2 = Tree(GIT_TEST_DIR2, GIT_REMOTE)
    local_repo2.fetch_ref('refs/test/testref', 'localrev')
    css = File(GIT_TEST_DIR2.child(CSS_FILE)).read_all()
    assert css == new_css
    assert local_repo2.get_revision(short=False) == revision
    assert local_repo2.get_last_committed() == modified