4 from git_remote_helpers
.util
import check_call
, die
, warn
7 class NonLocalGit(object):
8 """Handler to interact with non-local repos.
11 def __init__(self
, repo
):
12 """Creates a new non-local handler for the specified repo.
17 def clone(self
, base
):
18 """Clones the non-local repo to base.
20 Does nothing if a clone already exists.
23 path
= os
.path
.join(self
.repo
.get_base_path(base
), '.git')
26 if os
.path
.exists(path
):
30 args
= ["git", "clone", "--bare", "--quiet", self
.repo
.gitpath
, path
]
36 def update(self
, base
):
37 """Updates checkout of the non-local repo in base.
40 path
= os
.path
.join(self
.repo
.get_base_path(base
), '.git')
42 if not os
.path
.exists(path
):
43 die("could not find repo at %s", path
)
45 args
= ["git", "--git-dir=" + path
, "fetch", "--quiet", self
.repo
.gitpath
]
48 args
= ["git", "--git-dir=" + path
, "update-ref", "refs/heads/master", "FETCH_HEAD"]
49 child
= check_call(args
)
52 """Pushes from the non-local repo to base.
55 path
= os
.path
.join(self
.repo
.get_base_path(base
), '.git')
57 if not os
.path
.exists(path
):
58 die("could not find repo at %s", path
)
60 args
= ["git", "--git-dir=" + path
, "push", "--quiet", self
.repo
.gitpath
, "--all"]
61 child
= check_call(args
)