Skip to content

Instantly share code, notes, and snippets.

@ookiineko
Created May 5, 2022 12:26
Show Gist options
  • Save ookiineko/a7e605094b33f3ca2183a309f30ff02b to your computer and use it in GitHub Desktop.
Save ookiineko/a7e605094b33f3ca2183a309f30ff02b to your computer and use it in GitHub Desktop.
a replacement of git-repo sync
#!/usr/bin/env python3
from os import system, getcwd, chdir
from os.path import join, exists
root = getcwd()
with open('housekeeping.txt', 'r', encoding='utf-8') as f:
content = f.read()
for line in content.split('\n'):
stripped_line = line.strip()
if stripped_line:
path = join(root, stripped_line)
if exists(path):
chdir(path)
assert not system('git pull --rebase'), 'failed to pull %s' % stripped_line
else:
print('warning: %s does not exist!' % stripped_line)
chdir(root)
print('Done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment