Skip to content

Commit

Permalink
Resolves #39. Skipping repository if it is in broken condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasursadikov committed Sep 7, 2024
1 parent 2c850b3 commit fd9675a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mud.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,14 @@ def _filter_repos(self) -> None:
to_delete = []
for repo in self.repos:
os.chdir(os.path.join(directory, repo))
has_modifications = subprocess.check_output('git status --porcelain', shell=True)
branch_filter = (branch is not None and branch.strip() and subprocess.check_output('git rev-parse --abbrev-ref HEAD', shell=True, text=True).splitlines()[0] != branch)
is_diverged = not any('ahead' in line or 'behind' in line for line in subprocess.check_output('git status --branch --porcelain', shell=True, text=True).splitlines() if line.startswith('##'))
if (modified and not has_modifications) or (branch and branch_filter) or (diverged and is_diverged):
try:
has_modifications = subprocess.check_output('git status --porcelain', shell=True, stderr=subprocess.DEVNULL)
branch_filter = (branch is not None and branch.strip() and subprocess.check_output('git rev-parse --abbrev-ref HEAD', shell=True, text=True).splitlines()[0] != branch)
is_diverged = not any('ahead' in line or 'behind' in line for line in subprocess.check_output('git status --branch --porcelain', shell=True, text=True).splitlines() if line.startswith('##'))
if (modified and not has_modifications) or (branch and branch_filter) or (diverged and is_diverged):
to_delete.append(repo)
except Exception as e:
print(f'{BOLD}{YELLOW}{repo}{RESET} Error occurred. {RED}{e}{RESET}')
to_delete.append(repo)

for repo in to_delete:
Expand Down

0 comments on commit fd9675a

Please sign in to comment.