[Cryptech-Commits] [user/sra/build-tools] 01/02: Further trivial scripts.

git at cryptech.is git at cryptech.is
Sun Jun 19 18:52:18 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository user/sra/build-tools.

commit a07d639bf75fbe392a96ad91ffaeb0dbb63b865d
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Sun Jun 19 14:13:29 2016 -0400

    Further trivial scripts.
---
 repo-foreach.py | 24 ++++++++++++++++++++++++
 what-remotes.py | 14 ++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/repo-foreach.py b/repo-foreach.py
new file mode 100755
index 0000000..ea18a39
--- /dev/null
+++ b/repo-foreach.py
@@ -0,0 +1,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)
diff --git a/what-remotes.py b/what-remotes.py
new file mode 100755
index 0000000..0359301
--- /dev/null
+++ b/what-remotes.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+#
+# List rmotes in local repository tree.
+
+from subprocess import check_output
+from os         import walk, listdir
+from sys        import argv
+
+for root in argv[1:] or listdir("."):
+    for head, dirs, files in walk(root):
+        if ".git" in dirs and not head.endswith("/gitolite"):
+            print head
+            for line in check_output(("git", "remote", "-v"), cwd = head).splitlines():
+                print " ", line



More information about the Commits mailing list