Commits

Mike Bayer committed 065a26f

chdir back before continuing with listdir...

Comments (0)

Files changed (1)

publishthing/core.py

 import os
 from subprocess import check_call
 import sys
+import contextlib
+
 
 def update_git_mirror(path, origin):
     """Update a git repo that is mirroring with --mirror
     """
+    with chdir_as(path):
+        check_call(["git", "remote", "update", "--prune", origin])
+
+
+@contextlib.contextmanager
+def chdir_as(path):
+    currdir = os.getcwd()
     os.chdir(path)
-    check_call(["git", "remote", "update", "--prune", origin])
+    yield
+    os.chdir(currdir)
 
 
 def git_checkout_files(repo, work_dir, dirname):