chiark / gitweb /
Add a 'pull' command
[stgit] / stgit / git.py
index 1f5a129865fd7c7d6e2ed37b9206d9e5110dcab2..e05f99a74c9ebed7e846994948631d8b448271ea 100644 (file)
@@ -438,3 +438,18 @@ def switch(tree_id):
     # checkout doesn't remove files
     for fs in to_delete:
         os.remove(fs[1])
+
+def fetch(location, head = None, tag = None):
+    """Fetch changes from the remote repository. At the moment, just
+    use the 'git fetch' scripts
+    """
+    args = [location]
+    if head:
+        args += [head]
+    elif tag:
+        args += ['tag', tag]
+
+    if __run('git fetch', args) != 0:
+        raise GitException, 'Failed "git fetch %s"' % location
+
+    return read_string(os.path.join(base_dir, 'FETCH_HEAD'))