summaryrefslogtreecommitdiff
path: root/linaropy/git/gitrepo.py
diff options
context:
space:
mode:
authorRyan S. Arnold <ryan.arnold@linaro.org>2016-08-20 16:50:30 -0500
committerRyan S. Arnold <ryan.arnold@linaro.org>2016-08-20 16:50:30 -0500
commit2e634bbbd96a42819a6d6c5af74d5f5686a0c841 (patch)
treed6d19e35d3564cc110a19c81ba09d2efe8c8e337 /linaropy/git/gitrepo.py
parenta52c1b3a3721a5e7e922cf461b358364a4424643 (diff)
Move 'cd' context out of linaropy/git/gitrepo.py into linaropy/cd.py
It is useful outside of the context of using a git repo.
Diffstat (limited to 'linaropy/git/gitrepo.py')
-rw-r--r--linaropy/git/gitrepo.py23
1 files changed, 3 insertions, 20 deletions
diff --git a/linaropy/git/gitrepo.py b/linaropy/git/gitrepo.py
index ffc85d9..d885a75 100644
--- a/linaropy/git/gitrepo.py
+++ b/linaropy/git/gitrepo.py
@@ -8,27 +8,10 @@ from sh import ErrorReturnCode_128
import subprocess
-# Use this to manage 'cd' context
-from contextlib import contextmanager
-
from ..proj import Proj
-# Return to prevdir when context is exited.
-# Use in the following manner:
-#
-# with cd("foodir"):
-# operation1_in_foodir
-# operation2_in_foodir
-#
-# operation3_in_prevdir
-#
-@contextmanager
-def cd(newdir):
- prevdir = os.getcwd()
- os.chdir(os.path.expanduser(newdir))
- try:
- yield
- finally:
- os.chdir(prevdir)
+from ..cd import cd
+
+from contextlib import contextmanager
# This is called 'GitRepo' because a repository for a project doesn't only have
# to be a git repository. Abstract base class used to define the operations