Fix validate.py and test.py traversals

The get_modified_files call needs to be run from the doc directory
since we invoce it with --relative.

I noticed that we skipped validation of files in some case
and confirmed that this is now handled properly.

Change-Id: Ieaa5bfb2f7ada6345dba8b6b4116f17dff582fe1
Closes-Bug: #1228777
This commit is contained in:
Andreas Jaeger 2013-09-22 10:53:36 +02:00
parent e9a8d33e94
commit 374fc46f56
2 changed files with 21 additions and 9 deletions

View File

@ -155,7 +155,14 @@ def only_www_touched():
return www_changed and not other_changed
def get_modified_files():
def get_modified_files(rootdir):
"""Get modified files below doc directory"""
# There are several tree traversals in this program that do a
# chroot, we need to run this git command always from the rootdir,
# so assure that.
os.chdir(rootdir)
try:
args = ["git", "diff", "--name-only", "--relative", "HEAD", "HEAD~1"]
modified_files = check_output(args).strip().split()
@ -169,7 +176,7 @@ def check_deleted_files(rootdir, file_exceptions):
"""
print("\nChecking for removed files")
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
deleted_files = []
any_removed = False
for f in modified_files:
@ -228,11 +235,10 @@ def validate_individual_files(rootdir, exceptions, force=False, niceness=False,
schema = get_schema()
any_failures = False
modified_files = get_modified_files()
if force:
print("\nValidating all files")
else:
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
print("\nFollowing files will be validated:")
for f in modified_files:
print(">>> %s" % f)
@ -306,7 +312,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force=False,
This will throw an exception if a book fails to build
"""
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
modified_files = map(lambda x: os.path.abspath(x), modified_files)
affected_books = []
books = []

View File

@ -157,7 +157,13 @@ def only_www_touched():
return www_changed and not other_changed
def get_modified_files():
def get_modified_files(rootdir):
"""Get modified files below doc directory"""
# There are several tree traversals in this program that do a
# chroot, we need to run this git command always from the rootdir,
# so assure that.
os.chdir(rootdir)
try:
args = ["git", "diff", "--name-only", "--relative", "HEAD", "HEAD~1"]
modified_files = check_output(args).strip().split()
@ -172,7 +178,7 @@ def check_deleted_files(rootdir, file_exceptions):
"""
print("\nChecking for removed files")
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
deleted_files = []
any_removed = False
for f in modified_files:
@ -235,7 +241,7 @@ def validate_individual_files(rootdir, exceptions, force):
if force:
print("\nValidating all files")
else:
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
print("\nFollowing files will be validated:")
for f in modified_files:
print(">>> %s" % f)
@ -306,7 +312,7 @@ def build_affected_books(rootdir, book_exceptions, file_exceptions, force):
This will throw an exception if a book fails to build
"""
modified_files = get_modified_files()
modified_files = get_modified_files(rootdir)
modified_files = map(lambda x: os.path.abspath(x), modified_files)
affected_books = []
books = []