use git reset to check out specified commit
authorTimo Savola <tsavola@movial.fi>
Sun, 6 Apr 2008 07:40:57 +0000 (10:40 +0300)
committerTimo Savola <tsavola@movial.fi>
Sun, 6 Apr 2008 07:40:57 +0000 (10:40 +0300)
matrix/git.py
matrix/matrix.py

index f973b5a..a469ff3 100644 (file)
@@ -147,6 +147,17 @@ def checkout(name, branch=None):
 
        call(cmd, workdir=name, fail=True)
 
+def reset(name, commit=None, soft=False, hard=False):
+       cmd = ['reset', '-q']
+       if soft:
+               cmd.append('--soft')
+       if hard:
+               cmd.append('--hard')
+       if commit:
+               cmd.append(commit)
+
+       call(cmd, workdir=name, fail=True)
+
 def rev_parse(name, arg):
        lines = call_output(['rev-parse', '--verify', arg], workdir=name)
        if lines:
index 75cf265..347f499 100644 (file)
@@ -222,8 +222,8 @@ def update_component_depends(packages):
 
                        if not deppkg:
                                log.error('Package %s depends on ' \
-                                         'non-existent package %s', \
-                                         pkg.name, depname)
+                                         'non-existent package %s' % \
+                                         (pkg.name, depname))
                                continue
 
                        if deppkg.component == pkg.component:
@@ -321,9 +321,10 @@ def clone_repository(repo):
                        os.rename(tmpdb, repodb)
                finally:
                        os.rmdir(tmp)
-               git.checkout(repo.path)
        else:
-               git.clone(repo.path, repo.active_url, checkout=True)
+               git.clone(repo.path, repo.active_url, checkout=False)
+
+       git.reset(repo.path, repo.get_commit(), hard=True)
 
 def update_component_packages(c, targets, packages):
        c.active_packages = {}