Permalink
Browse files

Added tests and fixed KITCHEN-244.

  • Loading branch information...
1 parent 98e6a5a commit 8e19d7fa3e2ff20a267501c997f670e761d20744 bcwalrus committed Jan 22, 2010
Showing with 42 additions and 14 deletions.
  1. +13 −5 crepo.py
  2. +4 −1 git_repo.py
  3. +14 −7 manifest.py
  4. +5 −0 shell-tests/follow_hash.sh
  5. +6 −1 shell-tests/follow_indirect.sh
View
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# (c) Copyright 2009 Cloudera, Inc.
+# (c) Copyright 2010 Cloudera, Inc.
import os
import sys
import optparse
@@ -8,6 +8,7 @@
import textwrap
from git_command import GitCommand
from git_repo import GitRepo
+import trace
LOADED_MANIFEST = None
def load_manifest():
@@ -84,6 +85,7 @@ def sync(args):
continue
elif right > 0:
repo.check_command(["merge", project.tracker.remote_ref])
+ project.set_uptodate()
else:
print >>sys.stderr, "Project %s needs no update" % project.name
@@ -209,7 +211,7 @@ def fetch(args):
"""Run git-fetch in every project"""
def _filter(proj):
if proj.is_uptodate():
- print >>sys.stderr, "%s is already up to date" % (proj,)
+ print >>sys.stderr, "%s is already up-to-date" % (proj,)
return False
else:
return True
@@ -335,13 +337,19 @@ def dump_refs(args):
repo = get_manifest_repo()
if repo:
+ try:
+ repo_branch = repo.current_branch()
+ except Exception, ex:
+ trace.Trace("Failed to get current branch for %s: %s" % (repo, ex))
+ return
+
print
print "Manifest repo:"
print " HEAD: %s" % repo.rev_parse("HEAD")
- print " Symbolic: %s" % repo.current_branch()
+ print " Symbolic: %s" % repo_branch
repo_status(repo,
- repo.current_branch(),
- "origin/" + repo.current_branch(),
+ repo_branch,
+ "origin/" + repo_branch,
indent=2)
check_dirty_repo(repo, indent=2)
View
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# (c) Copyright 2009 Cloudera, Inc.
+# (c) Copyright 2010 Cloudera, Inc.
from git_command import GitCommand
import os
@@ -8,6 +8,9 @@ class GitRepo(object):
def __init__(self, path):
self.path = path
+ def __str__(self):
+ return "GitRepo at " + self.path
+
def command(self, cmdv, **kwargs):
"""
Runs the given git command and returns the status code returned.
View
@@ -1,12 +1,14 @@
#!/usr/bin/env python
-# (c) Copyright 2009 Cloudera, Inc.
+# (c) Copyright 2010 Cloudera, Inc.
import logging
import os
import re
import simplejson
+import sys
from git_command import GitCommand
from git_repo import GitRepo
+import trace
class Manifest(object):
@@ -201,10 +203,14 @@ def __init__(self,
self.remote_project_name = remote_project_name or name
# If this project tracks hash or indirect, it may already be up-to-date
try:
- self.__is_uptodate = \
- (self.tracker.remote_ref == self.git_repo.rev_parse("HEAD"))
- except Exception: # Error due to uninitialized project
- self.__is_uptodate = False
+ rev = self.git_repo.rev_parse("HEAD")
+ remote_ref = self.tracker.remote_ref
+ trace.Trace("<%s> %s (local) -- %s (remote)" %
+ (name, rev, remote_ref))
+ self.__is_uptodate = remote_ref == rev
+ except Exception, ex: # Error due to uninitialized project
+ trace.Trace("Non fatal error %s", ex)
+ self.__is_uptodate = False
def __str__(self):
return "Project %s" % (self.name,)
@@ -284,6 +290,9 @@ def git_repo(self):
def is_uptodate(self):
return self.__is_uptodate
+ def set_uptodate(self):
+ self.__is_uptodate = True
+
def is_cloned(self):
return self.git_repo.is_cloned()
@@ -308,7 +317,6 @@ def clone(self):
repo.check_command(["checkout", self.tracker.tracking_branch])
else:
repo.check_command(["checkout"])
- self.__is_uptodate = True
def ensure_remotes(self):
@@ -345,4 +353,3 @@ def checkout_tracking_branch(self):
"""Check out the correct tracking branch."""
self.ensure_tracking_branch()
self.git_repo.check_command(["checkout", self.tracker.tracking_branch])
- self.__is_uptodate = True
@@ -57,3 +57,8 @@ test $(git remote) == "origin"
test -f file_a
test -f file_b
popd
+
+# Now sync should say "already up-to-date"
+$CREPO sync 2>&1 | grep "already up-to-date"
+
+echo ALL GOOD
@@ -66,4 +66,9 @@ popd
# And update the indirects
$CREPO update-indirect -f
-test "$(cat .crepo/repo_a)" == "$COMMIT_C_HASH"
+test "$(cat .crepo/repo_a)" == "$COMMIT_C_HASH"
+
+# Now sync should say "already up-to-date"
+$CREPO sync 2>&1 | grep "already up-to-date"
+
+echo ALL GOOD

0 comments on commit 8e19d7f

Please sign in to comment.