Exemple #1
0
    def _diffed_paths(self) -> List[Path]:
        repo = bento.git.repo()
        if not repo:
            return []

        # Will always be relative to repo root
        cmd = [
            "git",
            "diff",
            "--name-only",
            "--no-ext-diff",
            "-z",
            # Everything except for D
            "--diff-filter=ACMRTUXB",
            "--staged",
        ]
        result = repo.git.execute(cmd)
        str_paths = zsplit(result)

        # Resolve paths relative to cwd
        return [
            self._base_path / ((Path(repo.working_tree_dir) /
                                p).resolve().relative_to(self._base_path))
            for p in str_paths
        ]
    def _staged_paths(self) -> List[Path]:
        """
            Returns Absolute Paths to all files that are staged
        """
        repo = bento.git.repo()
        if not repo:
            return []

        # Output of git command will be relative to git project root
        cmd = [
            "git",
            "diff",
            "--name-only",
            "--no-ext-diff",
            "-z",
            # Everything except for D
            "--diff-filter=ACMRTUXB",
            "--staged",
        ]
        result = repo.git.execute(cmd)
        str_paths = zsplit(result)

        # Resolve paths relative to git project root
        return [(Path(repo.working_tree_dir) / p).resolve() for p in str_paths]
def test_zsplit(s, expected):
    assert git.zsplit(s) == expected
Exemple #4
0
def test_zsplit(s, expected):
    assert git.zsplit(s) == expected