aboutsummaryrefslogtreecommitdiff
path: root/repo-foreach.py
blob: ea18a39733e63829f5e9a1331c70b6e6238cc4e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
#
# Perform some command for every repository in a tree

from subprocess import call
from os         import walk
from argparse   import ArgumentParser
from sys        import exit

parser = ArgumentParser()
parser.add_argument("-t", "--tree", default = ".", help = "repository tree to walk")
parser.add_argument("-v", "--verbose", action = "store_true", help = "whistle while you work")
parser.add_argument("command", nargs = "+", help = "command to run in each repository")
args = parser.parse_args()

status = 0

for head, dirs, files in walk(args.tree):
    if ".git" in dirs and not head.endswith("/gitolite"):
        if args.verbose:
            print head
        status |= call(args.command, cwd = head)

exit(status)