code: def detect_spurious_commit(actual, expected, remote):
      """GitHub sometimes spuriously generates commits multiple times with
      different dates but identical contents. See here:
      https://github.com/travis-ci/travis-ci/issues/7459#issuecomment-601346831
      We need to detect whether this might be the case, and we do so by
      comparing the commits' contents ("tree" objects) and their parents.
  
      Args:
          actual: The commit line on the remote from git ls-remote, e.g.:
              da39a3ee5e6b4b0d3255bfef95601890afd80709    refs/heads/master
          expected: The commit line initially expected.
  
      Returns:
          The new (actual) commit line, if it is suspected to be spurious.
          Otherwise, the previously expected commit line.
      """
      actual_hash = actual.split(None, 1)[0]
      expected_hash = expected.split(None, 1)[0]
      relevant = [
          "tree",
          "parent",
      ]  # relevant parts of a commit for comparison
      if actual != expected:
          git("fetch", "-q", remote, actual_hash)
          actual_info = get_commit_metadata(actual_hash)
          expected_info = get_commit_metadata(expected_hash)
          a = [pair for pair in actual_info if pair[0] in relevant]
          b = [pair for pair in expected_info if pair[0] in relevant]
          if a == b:
              expected = actual
      return expected
  
imports: import argparse
  import errno
  import logging
  import os
  import signal
  import subprocess
  import sys
  import time
label_desc: Use image node_id 11 for calling a global function with example usage: detect_spurious_commit(actual, expected, remote) and returns: expected