# Path: therapist/utils/git/git.py
# class Git(object):
#     def __init__(self, cmd=None, repo_path=None):
#         self.repo_path = repo_path
#         self.current = list(cmd) if cmd else ["git"]
# 
#     def __call__(self, *args, **kwargs):
#         cmd = self.current + to_cli_args(*args, **kwargs)
# 
#         subprocess_kwargs = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
# 
#         if self.repo_path:
#             subprocess_kwargs["cwd"] = self.repo_path
# 
#         pipes = subprocess.Popen(cmd, **subprocess_kwargs)
#         out, err = pipes.communicate()
#         return out.decode("utf-8"), err.decode("utf-8"), pipes.returncode
# 
#     def __getattr__(self, name):
#         name = name.replace("_", "-")
#         return Git(self.current + [name], repo_path=self.repo_path)
# 
#     def __str__(self):  # pragma: no cover
#         return str(self.current)
# 
#     def __repr__(self):  # pragma: no cover
#         return "<Git {}>".format(str(self))
# 
# Path: therapist/utils/git/status.py
# class Status(object):
#     def __init__(self, status):
#         matches = re.search(r"^([MADRCU ?!]{2}) (.+?)(?: -> (.+?))?$", status)
#         self.x = matches[1][0]
#         self.y = matches[1][1]
#         self.path = matches[3] if matches[3] else matches[2]
#         self.original_path = matches[2] if matches[3] else None
# 
#     def __str__(self):
#         status = "{}{}".format(self.x, self.y)
#         if self.original_path:
#             status = "{} {} -> {}".format(status, self.original_path, self.path)
#         else:
#             status = "{} {}".format(status, self.path)
#         return status
# 
#     def __repr__(self):  # pragma: no cover
#         return "<Status {}>".format(self.path)
# 
#     @property
#     def is_staged(self):
#         return self.x not in (" ", "?", "!")
# 
#     @property
#     def is_untracked(self):
#         return self.x == "?"
# 
#     @property
#     def is_ignored(self):
#         return self.x == "!"


import os
from therapist.utils.git import Git, Status

                    # Skip deleted files
                    if file_status.x == "D" or (include_unstaged and file_status.y == "D"):
                        continue

                    files.append(file_status.path)

        for path in files:
            if os.path.exists(path):
                self.file_mtimes[path] = os.path.getmtime(path)

        self.files = files

    def run_process(self, process):
        """Runs a single action."""
        message = u"#{bright}"
        message += u"{} ".format(str(process)[:68]).ljust(69, ".")

        stashed = False
        if self.git and self.unstaged_changes and not self.include_unstaged_changes:
            out, err, code = self.git.stash(keep_index=True, quiet=True)
            stashed = code == 0

        try:
            result = process(files=self.files, cwd=self.cwd, fix=self.fix)

            # Check for modified files
            if self.git:
                out, err, code = self.git.status(porcelain=True, untracked_files="no")
                for line in out.splitlines():

# Path: therapist/utils/git/git.py
# class Git(object):
#     def __init__(self, cmd=None, repo_path=None):
#         self.repo_path = repo_path
#         self.current = list(cmd) if cmd else ["git"]
# 
#     def __call__(self, *args, **kwargs):
#         cmd = self.current + to_cli_args(*args, **kwargs)
# 
#         subprocess_kwargs = {"stdout": subprocess.PIPE, "stderr": subprocess.PIPE}
# 
#         if self.repo_path:
#             subprocess_kwargs["cwd"] = self.repo_path
# 
#         pipes = subprocess.Popen(cmd, **subprocess_kwargs)
#         out, err = pipes.communicate()
#         return out.decode("utf-8"), err.decode("utf-8"), pipes.returncode
# 
#     def __getattr__(self, name):
#         name = name.replace("_", "-")
#         return Git(self.current + [name], repo_path=self.repo_path)
# 
#     def __str__(self):  # pragma: no cover
#         return str(self.current)
# 
#     def __repr__(self):  # pragma: no cover
#         return "<Git {}>".format(str(self))
# 
# Path: therapist/utils/git/status.py
# class Status(object):
#     def __init__(self, status):
#         matches = re.search(r"^([MADRCU ?!]{2}) (.+?)(?: -> (.+?))?$", status)
#         self.x = matches[1][0]
#         self.y = matches[1][1]
#         self.path = matches[3] if matches[3] else matches[2]
#         self.original_path = matches[2] if matches[3] else None
# 
#     def __str__(self):
#         status = "{}{}".format(self.x, self.y)
#         if self.original_path:
#             status = "{} {} -> {}".format(status, self.original_path, self.path)
#         else:
#             status = "{} {}".format(status, self.path)
#         return status
# 
#     def __repr__(self):  # pragma: no cover
#         return "<Status {}>".format(self.path)
# 
#     @property
#     def is_staged(self):
#         return self.x not in (" ", "?", "!")
# 
#     @property
#     def is_untracked(self):
#         return self.x == "?"
# 
#     @property
#     def is_ignored(self):
#         return self.x == "!"


# Path: therapist/runner/runner.py
import os
from therapist.utils.git import Git, Status


                    # Skip deleted files
                    if file_status.x == "D" or (include_unstaged and file_status.y == "D"):
                        continue

                    files.append(file_status.path)

        for path in files:
            if os.path.exists(path):
                self.file_mtimes[path] = os.path.getmtime(path)

        self.files = files

    def run_process(self, process):
        """Runs a single action."""
        message = u"#{bright}"
        message += u"{} ".format(str(process)[:68]).ljust(69, ".")

        stashed = False
        if self.git and self.unstaged_changes and not self.include_unstaged_changes:
            out, err, code = self.git.stash(keep_index=True, quiet=True)
            stashed = code == 0

        try:
            result = process(files=self.files, cwd=self.cwd, fix=self.fix)

            # Check for modified files
            if self.git:
                out, err, code = self.git.status(porcelain=True, untracked_files="no")
                for line in out.splitlines():

                    file_status = Status(line)