예제 #1
0
def test_diff():
    with _git_directory() as t:
        io.write_file(os.path.join(t, "README"), "new docs")
        _add_and_commit(t, ["README"])
        io.write_file(os.path.join(t, "file1"), "file1")
        _add_and_commit(t, ["file1"])
        io.write_file(os.path.join(t, "file1"), "file1 changed")
        _add_and_commit(t, ["file1"])
        assert git.diff(None, t, "HEAD~..HEAD") == ["file1"]
        assert "README" in git.diff(None, t, "HEAD~~~..HEAD")
예제 #2
0
파일: test_git.py 프로젝트: yuanbit/planemo
def test_diff():
    with _git_directory() as t:
        io.write_file(os.path.join(t, "README"), "new docs")
        _add_and_commit(t, ["README"])
        io.write_file(os.path.join(t, "file1"), "file1")
        _add_and_commit(t, ["file1"])
        io.write_file(os.path.join(t, "file1"), "file1 changed")
        _add_and_commit(t, ["file1"])
        assert git.diff(None, t, "HEAD~..HEAD") == ["file1"]
        assert "README" in git.diff(None, t, "HEAD~~~..HEAD")
예제 #3
0
def filter_paths(ctx, raw_paths, path_type="repo", **kwds):
    """Filter ``paths``.

    ``path_type`` is ``repo`` or ``file``.
    """
    cwd = os.getcwd()

    filter_kwds = copy.deepcopy(kwds)
    changed_in_commit_range = kwds.get("changed_in_commit_range", None)
    diff_paths = None
    if changed_in_commit_range is not None:
        diff_files = git.diff(ctx, cwd, changed_in_commit_range)
        if path_type == "repo":
            diff_dirs = set(os.path.dirname(p) for p in diff_files)
            diff_paths = set()
            for diff_dir in diff_dirs:
                while diff_dir:
                    if os.path.isfile(os.path.join(diff_dir,
                                                   SHED_CONFIG_NAME)):
                        diff_paths.add(diff_dir)
                        break
                    diff_dir = os.path.dirname(diff_dir)
        else:
            diff_paths = diff_files

    unique_paths = set(os.path.relpath(p, cwd) for p in raw_paths)
    if diff_paths is not None:
        new_unique_paths = []
        for path in unique_paths:
            if path in diff_paths:
                new_unique_paths.append(path)
        unique_paths = new_unique_paths
    filtered_paths = sorted(
        io.filter_paths(unique_paths, cwd=cwd, **filter_kwds))
    excluded_paths = sorted(set(unique_paths) - set(filtered_paths))
    if excluded_paths:
        ctx.log("List of excluded paths: %s" % excluded_paths)

    path_count = len(filtered_paths)
    chunk_size = ((1.0 * path_count) / kwds["chunk_count"])
    chunk = kwds["chunk"]

    chunked_paths = []
    for i, path in enumerate(filtered_paths):
        if int(math.floor(i / chunk_size)) == chunk:
            chunked_paths.append(path)

    return chunked_paths
예제 #4
0
파일: ci.py 프로젝트: galaxyproject/planemo
def filter_paths(ctx, raw_paths, path_type="repo", **kwds):
    """Filter ``paths``.

    ``path_type`` is ``repo`` or ``file``.
    """
    cwd = os.getcwd()

    filter_kwds = copy.deepcopy(kwds)
    changed_in_commit_range = kwds.get("changed_in_commit_range", None)
    diff_paths = None
    if changed_in_commit_range is not None:
        diff_files = git.diff(ctx, cwd, changed_in_commit_range)
        if path_type == "repo":
            diff_dirs = set(os.path.dirname(p) for p in diff_files)
            diff_paths = set()
            for diff_dir in diff_dirs:
                while diff_dir:
                    if os.path.isfile(os.path.join(diff_dir, SHED_CONFIG_NAME)):
                        diff_paths.add(diff_dir)
                        break
                    diff_dir = os.path.dirname(diff_dir)
        else:
            diff_paths = diff_files

    unique_paths = set(os.path.relpath(p, cwd) for p in raw_paths)
    if diff_paths is not None:
        new_unique_paths = []
        for path in unique_paths:
            if path in diff_paths:
                new_unique_paths.append(path)
        unique_paths = new_unique_paths
    filtered_paths = sorted(io.filter_paths(unique_paths, cwd=cwd, **filter_kwds))
    excluded_paths = sorted(set(unique_paths) - set(filtered_paths))
    if excluded_paths:
        ctx.log("List of excluded paths: %s" % excluded_paths)

    path_count = len(filtered_paths)
    chunk_size = ((1.0 * path_count) / kwds["chunk_count"])
    chunk = kwds["chunk"]

    chunked_paths = []
    for i, path in enumerate(filtered_paths):
        if int(math.floor(i / chunk_size)) == chunk:
            chunked_paths.append(path)

    return chunked_paths
예제 #5
0
파일: ci.py 프로젝트: stevecassidy/planemo
def filter_paths(ctx, raw_paths, path_type="dir", **kwds):
    """Filter ``paths``.

    ``path_type`` is ``dir`` or ``file``.
    """
    cwd = os.getcwd()

    filter_kwds = copy.deepcopy(kwds)
    changed_in_commit_range = kwds.get("changed_in_commit_range", None)
    diff_paths = None
    if changed_in_commit_range is not None:
        diff_files = git.diff(ctx, cwd, changed_in_commit_range)
        if path_type == "dir":
            diff_paths = [os.path.dirname(p) for p in diff_files]
        else:
            diff_paths = diff_files
        diff_paths = sorted(set(diff_paths))

    unique_paths = sorted(
        set(map(lambda p: os.path.relpath(p, cwd), raw_paths)))
    filtered_paths = io.filter_paths(unique_paths, cwd=cwd, **filter_kwds)
    if diff_paths is not None:
        new_filtered_paths = []
        for path in filtered_paths:
            if path in diff_paths:
                new_filtered_paths.append(path)

        filtered_paths = new_filtered_paths

    path_count = len(filtered_paths)
    chunk_size = ((1.0 * path_count) / kwds["chunk_count"])
    chunk = kwds["chunk"]

    chunked_paths = []
    for i, path in enumerate(filtered_paths):
        if int(math.floor(i / chunk_size)) == chunk:
            chunked_paths.append(path)

    return chunked_paths