Пример #1
0
def update_dist():
    if not os.path.exists(built_dir) or not vcs.is_git_root(built_dir):
        git = vcs.git
        git("clone", remote_built, built_dir)
    else:
        git = vcs.bind_to_repo(vcs.git, built_dir)
        git("fetch")
        if "origin/master" in git("branch", "-a"):
            git("checkout", "master")
            git("merge", "--ff-only", "origin/master")

    git = vcs.bind_to_repo(vcs.git, built_dir)
    git("config", "user.email", "*****@*****.**")
    git("config", "user.name", "CSS Build Bot")
Пример #2
0
def add_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    dest_path = os.path.join(built_dir, "source_rev")
    with open(dest_path, "w") as f:
        f.write(changeset)
    git("add", os.path.relpath(dest_path, built_dir))
Пример #3
0
def add_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    dest_path = os.path.join(built_dir, "source_rev")
    with open(dest_path, "w") as f:
        f.write(changeset)
    git("add", os.path.relpath(dest_path, built_dir))
Пример #4
0
def update_source():
    if not os.path.exists(hg_dir) or not os.path.exists(os.path.join(hg_dir, ".hg")):
        hg = vcs.hg
        hg("clone", remote_hg, hg_dir)
    else:
        hg = vcs.bind_to_repo(vcs.hg, hg_dir)
        hg("pull")
        hg("update")
Пример #5
0
def get_new_commits():
    git = vcs.bind_to_repo(vcs.git, source_dir)
    commit_path = os.path.join(built_dir, "source_rev")
    with open(commit_path) as f:
        prev_commit = f.read().strip()

    commit_range = "%s..%s" % (prev_commit, os.environ['TRAVIS_COMMIT'])
    return reversed(git("log", "--pretty=%H", "-r", commit_range).strip().split("\n"))
Пример #6
0
def apply_build_system_fixes():
    fixes = [
        "c017547f65e07bdd889736524d47824d032ba2e8",
        "cb4a737a88aa7e2f4e54383c57ffa2dfae093dcf"
    ]
    git = vcs.bind_to_repo(vcs.git, source_dir)
    for fix in fixes:
        git("cherry-pick", "--keep-redundant-commits", fix)
Пример #7
0
def list_current_files():
    git = vcs.bind_to_repo(vcs.git, built_dir)
    paths = [
        item for item in git("ls-tree", "-r", "--full-name", "--name-only",
                             "HEAD").split("\n")
        if item and item not in local_files
    ]
    return set(paths)
Пример #8
0
def apply_build_system_fixes():
    fixes = [
        "c017547f65e07bdd889736524d47824d032ba2e8",
        "cb4a737a88aa7e2f4e54383c57ffa2dfae093dcf",
        "ec540343a3e729644c8178dbcf6d063dca20d49f",
    ]
    git = vcs.bind_to_repo(vcs.git, source_dir)
    for fix in fixes:
        git("cherry-pick", "--keep-redundant-commits", fix)
Пример #9
0
def update_dist():
    if not os.path.exists(out_dir) or not vcs.is_git_root(out_dir):
        git = vcs.git
        git("clone", remote_git, out_dir)
    else:
        git = vcs.bind_to_repo(vcs.git, out_dir)
        git("fetch")
        if "origin/master" in git("branch", "-a"):
            git("checkout", "master")
            git("merge", "--ff-only", "origin/master")
Пример #10
0
def get_new_commits():
    hg = vcs.bind_to_repo(vcs.hg, hg_dir)
    commit_path = os.path.join(out_dir, "source_rev")
    if os.path.exists(commit_path):
        with open(commit_path) as f:
            prev_commit = f.read().strip()
        changesets = hg("log", "--template", "{node}\n", "-r", "%s.." % prev_commit).strip().split("\n")[1:]
    else:
        changesets = [hg("log", "--template", "{node}\n", "-r", "tip")]

    return changesets
Пример #11
0
def get_new_commits():
    git = vcs.bind_to_repo(vcs.git, source_dir)
    commit_path = os.path.join(built_dir, "source_rev")
    with open(commit_path) as f:
        prev_commit = f.read().strip()

    commit_range = "{0!s}..{1!s}".format(prev_commit, os.environ['TRAVIS_COMMIT'])
    commits = git("log", "--pretty=%H", "-r", commit_range).strip()
    if not commits:
        return []
    return reversed(commits.split("\n"))
Пример #12
0
def update_git(old_files, new_files):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    print old_files - new_files
    for item in old_files - new_files:
        git("rm", item)

    for item in new_files - old_files:
        git("add", item)

    git("add", "-u")
Пример #13
0
def update_git(old_files, new_files):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    print old_files - new_files
    for item in old_files - new_files:
        git("rm", item)

    for item in new_files - old_files:
        git("add", item)

    git("add", "-u")
Пример #14
0
def update_git(old_files, new_files):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    removed = sorted(old_files - new_files)
    added = sorted(new_files - old_files)

    for r in grouper(10, removed):
        git("rm", *r)

    for a in grouper(10, added):
        git("add", *a)

    git("add", "-u")
Пример #15
0
def update_git(old_files, new_files):
    git = vcs.bind_to_repo(vcs.git, built_dir)

    removed = sorted(old_files - new_files)
    added = sorted(new_files - old_files)

    for r in grouper(10, removed):
        git("rm", *r)

    for a in grouper(10, added):
        git("add", *a)

    git("add", "-u")
Пример #16
0
def push():
    git = vcs.bind_to_repo(vcs.git, out_dir)
    success = False
    for i in range(2):
        try:
            git("push", "origin", "HEAD:master")
        except subprocess.CalledProcessError:
            if i == 0:
                git("fetch", "origin")
                git("rebase", "origin/master")
        else:
            success = True
            break
    if not success:
        print "Push failed"
Пример #17
0
def copy_files():
    dist_path = os.path.join(hg_dir, "dist")
    git = vcs.bind_to_repo(vcs.git, out_dir)
    dest_paths = []
    for dir_name, dir_names, file_names in os.walk(dist_path):
        for file_name in file_names:
            src_path = os.path.join(dir_name, file_name)
            rel_path = os.path.relpath(src_path, dist_path)
            dest_path = os.path.join(out_dir, rel_path)
            dest_dir = os.path.dirname(dest_path)
            if not os.path.exists(dest_dir):
                os.makedirs(dest_dir)
            shutil.copy2(src_path, dest_path)
            dest_paths.append(os.path.relpath(dest_path, out_dir))

    return set(dest_paths)
Пример #18
0
def get_new_commits():
    git = vcs.bind_to_repo(vcs.git, source_dir)
    commit_path = os.path.join(built_dir, "source_rev")
    with open(commit_path) as f:
        prev_commit = f.read().strip()

    if git("rev-parse", "--revs-only", prev_commit).strip() != prev_commit:
        # we don't have prev_commit in current tree, so let's just do what's new
        commit_range = os.environ['TRAVIS_COMMIT_RANGE']
        assert (os.environ["TRAVIS_PULL_REQUEST"] != "false" or
                os.environ["TRAVIS_BRANCH"] != "master")
    else:
        merge_base = git("merge-base", prev_commit, os.environ['TRAVIS_COMMIT']).strip()
        commit_range = "%s..%s" % (merge_base, os.environ['TRAVIS_COMMIT'])

    commits = git("log", "--pretty=%H", "-r", commit_range).strip()
    if not commits:
        return []
    return reversed(commits.split("\n"))
Пример #19
0
def get_new_commits():
    git = vcs.bind_to_repo(vcs.git, source_dir)
    commit_path = os.path.join(built_dir, "source_rev")
    with open(commit_path) as f:
        prev_commit = f.read().strip()

    if git("rev-parse", "--revs-only", prev_commit).strip() != prev_commit:
        # we don't have prev_commit in current tree, so let's just do what's new
        commit_range = os.environ['TRAVIS_COMMIT_RANGE']
        assert (os.environ["TRAVIS_PULL_REQUEST"] != "false" or
                os.environ["TRAVIS_BRANCH"] != "master")
    else:
        merge_base = git("merge-base", prev_commit, os.environ['TRAVIS_COMMIT']).strip()
        commit_range = "%s..%s" % (merge_base, os.environ['TRAVIS_COMMIT'])

    commits = git("log", "--pretty=%H", "-r", commit_range).strip()
    if not commits:
        return []
    return reversed(commits.split("\n"))
Пример #20
0
def maybe_push():
    if os.environ["TRAVIS_PULL_REQUEST"] != "false":
        return

    if os.environ["TRAVIS_BRANCH"] != "master":
        return

    git = vcs.bind_to_repo(vcs.git, built_dir)

    out = "https://%[email protected]/jgraham/css-test-built.git" % os.environ["TOKEN"]
    git("remote", "add", "out", out, quiet=True)

    for i in range(2):
        try:
            git("push", "out", "HEAD:master")
        except subprocess.CalledProcessError:
            if i == 0:
                git("fetch", "origin")
                git("rebase", "origin/master")
        else:
            return

    raise Exception("Push failed")
Пример #21
0
def maybe_push():
    if os.environ["TRAVIS_PULL_REQUEST"] != "false":
        return

    if os.environ["TRAVIS_BRANCH"] != "master":
        return

    git = vcs.bind_to_repo(vcs.git, built_dir)

    out = "https://%[email protected]/jgraham/css-test-built.git" % os.environ["TOKEN"]
    git("remote", "add", "out", out, quiet=True)

    for i in range(2):
        try:
            git("push", "out", "HEAD:master")
        except subprocess.CalledProcessError:
            if i == 0:
                git("fetch", "origin")
                git("rebase", "origin/master")
        else:
            return

    raise Exception("Push failed")
Пример #22
0
def list_current_files():
    git = vcs.bind_to_repo(vcs.git, built_dir)
    paths = [item for item in git("ls-tree", "-r", "--full-name", "--name-only", "HEAD").split("\n")
             if item and item not in local_files]
    return set(paths)
Пример #23
0
def update_to_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, source_dir)
    git("checkout", changeset)
Пример #24
0
def update_to_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, source_dir)
    git("checkout", changeset)
    apply_build_system_fixes()
Пример #25
0
def update_git():
    git = vcs.bind_to_repo(vcs.git, built_dir)
    git("add", ".")
Пример #26
0
def commit(changeset):
    git = vcs.bind_to_repo(vcs.git, out_dir)
    hg = vcs.bind_to_repo(vcs.hg, hg_dir)
    msg = hg("log", "-r", changeset, "--template", "{desc}")
    msg = "%s\n\nBuild from revision %s" % (msg, changeset)
    git("commit", "-m", msg)
Пример #27
0
def update_git():
    git = vcs.bind_to_repo(vcs.git, built_dir)
    git("add", ".")
Пример #28
0
def update_to_changeset(changeset):
    hg = vcs.bind_to_repo(vcs.hg, hg_dir)
    hg("update", changeset)
Пример #29
0
 def __init__(self, root=None):
     if root is None:
         root = hg("root").strip()
     self.root = root
     self.hg = vcs.bind_to_repo(hg, self.root)
Пример #30
0
def update_to_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, source_dir)
    git("checkout", changeset)
    apply_build_system_fixes()
Пример #31
0
 def __init__(self, root=None):
     if root is None:
         root = git("rev-parse", "--show-toplevel").strip()
     self.root = root
     self.git = vcs.bind_to_repo(git, self.root)
     self.message = None
Пример #32
0
def update_to_changeset(changeset):
    git = vcs.bind_to_repo(vcs.git, source_dir)
    git("checkout", changeset)