Add check for stagnant shas in .gitignore
The only remaining problem is the site/.gitignore now is only able to
deal with lobs. I can still add begin/end tags to reserve only a part
of the file.
Bug: 1260479
Change-Id: I3b0ea50e3a5fffcbd2ea7ed18a4a97dc8b7fee4f
Reviewed-on: https://chromium-review.googlesource.com/c/experimental/website/+/3251316
Auto-Submit: Struan Shrimpton <sshrimp@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Struan Shrimpton <sshrimp@google.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index c4c06a8..acd7d54 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -69,3 +69,19 @@
break
return output_status
+
+def CheckLobIgnores(input_api, output_api):
+ output_status = []
+ with open("site/.gitignore", 'r+') as ignore_file:
+ ignored_lobs = set(line.rstrip() for line in ignore_file.readlines())
+
+ for ignored_lob in ignored_lobs:
+ lob_sha_file = os.path.join('site', ignored_lob + '.sha1')
+ if not os.path.exists(lob_sha_file):
+ error_msg = ('The sha1 file \'{removed_file}\' no longer exists, '
+ 'please remove {ignored_file} from site/.gitignore'
+ .format(removed_file = lob_sha_file, ignored_file = ignored_lob))
+
+ error = output_api.PresubmitError(error_msg)
+ output_status.append(error)
+ return output_status
\ No newline at end of file