Index: py/utils/git_utils.py |
diff --git a/py/utils/git_utils.py b/py/utils/git_utils.py |
index 52ad83a6409fd4ff17853e966ba69b68775cdc28..9abde2e1506b3773c47522fb9e279046ad745fbd 100644 |
--- a/py/utils/git_utils.py |
+++ b/py/utils/git_utils.py |
@@ -152,8 +152,8 @@ class GitBranch(object): |
class NewGitCheckout(object): |
"""Creates a new local checkout of a Git repository.""" |
- def __init__(self, repository, refspec=None, subdir=None, |
- containing_dir=None): |
+ def __init__(self, repository, branch='master', commithash='HEAD', |
+ subdir=None, containing_dir=None): |
"""Check out a new local copy of the repository. |
Because this is a new checkout, rather than a reference to an existing |
@@ -168,9 +168,12 @@ class NewGitCheckout(object): |
# the checkout is automatically cleaned up here |
Args: |
- repository: name of the remote repository |
- refspec: an arbitrary remote ref (e.g., the name of a branch); |
- if None, allow the git command to pick a default |
+ repository: URL of the remote repository (e.g., |
+ 'https://skia.googlesource.com/common') or path to a local repository |
+ (e.g., '/path/to/repo/.git') to check out a copy of |
+ branch: which branch to fetch from the repository |
+ commithash: rewind the local checkout to a particular commithash (which |
+ must be present along the branch specified above) |
subdir: if specified, the caller only wants access to files within this |
subdir in the repository. |
For now, we check out the entire repository regardless of this param, |
@@ -188,11 +191,13 @@ class NewGitCheckout(object): |
else: |
self._file_root = self._git_root |
- pull_cmd = [GIT, 'pull', repository] |
- if refspec: |
- pull_cmd.append(refspec) |
+ local_branch_name = 'local' |
self._run_in_git_root(args=[GIT, 'init']) |
- self._run_in_git_root(args=pull_cmd) |
+ self._run_in_git_root(args=[GIT, 'fetch', repository, branch]) |
+ self._run_in_git_root(args=[GIT, 'merge', 'FETCH_HEAD']) |
+ self._run_in_git_root(args=[GIT, 'branch', local_branch_name, commithash]) |
+ self._run_in_git_root(args=[GIT, 'checkout', local_branch_name]) |
borenet
2014/08/19 14:30:31
Why not just do:
$ git clone <repository>
$ git ch
epoger
2014/08/19 15:16:03
Seems to work (with some adjustments). I think th
borenet
2014/08/19 15:24:28
What repository are we checking out? I think Skia
epoger
2014/08/19 15:42:05
The primary use case is indeed the Skia repo. Per
borenet
2014/08/19 15:50:20
SGTM. You're welcome to change it back if you wan
|
+ |
@property |
def root(self): |