pre-upload: Bypass checkpatch for UPSTREAM and FROMGIT cherry picks

Bypass checkpatch for UPSTREAM and FROMGIT commits, since we do not
intend to modify the upstream commits when landing them to our branches.
Any fixes should sent as independent patches.

Keep the checks for FROMLIST and BACKPORT commits, as by definition they
can be still fixed up.

BUG=b:169141405
TEST=repo upload a long chain of CHROMIUM, BACKPORT, UPSTREAM and
     FROMLIST commits.

Change-Id: I9ba6329432477963eb3488af85bd01aa770d39bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/repohooks/+/2424266
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Commit-Queue: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 56209f1..9199299 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -1664,6 +1664,15 @@
 
 def _run_checkpatch(_project, commit, options=()):
   """Runs checkpatch.pl on the given project"""
+  # Bypass checkpatch for upstream or almost upstream commits, since we do not
+  # intend to modify the upstream commits when landing them to our branches.
+  # Any fixes should sent as independent patches.
+  # The check is retained for FROMLIST and BACKPORT commits, as by definition
+  # those can be still fixed up.
+  desc = _get_commit_desc(commit)
+  if desc.startswith('UPSTREAM:') or desc.startswith('FROMGIT:'):
+    return None
+
   hooks_dir = _get_hooks_dir()
   options = list(options)
   if options and options[0].startswith('./') and os.path.exists(options[0]):