Skip to content

Instantly share code, notes, and snippets.

@matthewdeanmartin
Created February 5, 2023 03:02
Show Gist options
  • Save matthewdeanmartin/e8af93e8cd0f49dd39983613f337ac56 to your computer and use it in GitHub Desktop.
Save matthewdeanmartin/e8af93e8cd0f49dd39983613f337ac56 to your computer and use it in GitHub Desktop.
Fixes Chmod+x for all the bash files on Windows.
import os
import subprocess
def run_git_command(directory: str, file: str):
os.chdir(directory)
subprocess.run(['git', 'add', '--chmod', '+x', file])
def find_git_repos(root_dir: str) -> tuple[str, str]:
for dirpath, dirnames, filenames in os.walk(root_dir):
if '.git' in dirnames:
for filename in filenames:
if filename.endswith('.sh'):
yield (dirpath, filename)
if __name__ == '__main__':
root_dir = 'e:\\repos'
for directory, filename in find_git_repos(root_dir):
run_git_command(directory, filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment