Don't try to read non-existant files in _verify_header_content.
If you're trying to upload a series of CLs, each is run through the
verification hooks before they're actually sent to the server. In
_verify_header_content, it first gets a list of files that are involved in the
CL, and then for each of them opens the file and checks for an appropriate
copyright header at the top.
The problem is, it opens the file from the filesystem directly, and that means
it will see whatever is in your current checkout, most likely the result of
the topmost CL, not the result of the CL its trying to verify.
This can be especially problematic when a file is changed and then later
deleted since the script will try to open a non-existant file. It won't just
check the wrong thing, it'll crash and fail. To avoid that particlar problem,
this change adds a check and skips over files that no longer exist.
Ideally what it would do is to actually retrieve the contents of the file in
question as it would appear after the CL that's being verified. That would
involve several extra calls to git which might add enough overhead to be
noticable, although there's a good chance it would be fast enough to not
matter. It also seems better to make sure the script won't crash right now and
then worry about a more complete/correct fix as time permits.
TEST=Ran repo upload on a branch where a file was modified and then deleted
and saw the verification script crash. Ran it again with this modification and
saw the crash go away.
Signed-off-by: Gabe Black <firstname.lastname@example.org>
Reviewed-by: David James <email@example.com>
Commit-Queue: Gabe Black <firstname.lastname@example.org>
Tested-by: Gabe Black <email@example.com>
1 file changed