libchrome: apply_patches: tag HEAD-before-patching commit in apply mode

For resetting state to commit before applying patches in format mode
(to be implemented) which would format applied patches and rename them
back to the original patch name.

If the tag already exists, the script will try to determine if it is
from a related run (e.g. multiple runs with different --first, --last
arg on top of the same HEAD-before-patching commit) by checking whether
all commits since that commit is a patch commit (with a valid patch-name
trailer in its commit message).
If so, skip re-tagging; otherwise abort and remind user to either remove
the obsolete tag or fix the patch commit messages.

In addition, check that the patch commits since HEAD-before-patching are
applied in the same order as it does during `emerge libchrome`, and
abort if not.

BUG=b:293001194
TEST=python -m unittest test_apply_patches
TEST=sudo emerge libchrome
TEST=run script in libchrome repo

Change-Id: I19e731bc1b7fc3bbe0933171f0da270dfebe70c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/libchrome/+/4812608
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Tested-by: Grace Cham <hscham@chromium.org>
Commit-Queue: Grace Cham <hscham@chromium.org>
2 files changed
tree: f42df15645ab526122b006043e2eca859b141756
  1. base/
  2. build/
  3. components/
  4. crypto/
  5. dbus/
  6. device/
  7. ipc/
  8. libchrome_tools/
  9. mojo/
  10. soong/
  11. testing/
  12. third_party/
  13. ui/
  14. .gitignore
  15. BASE_VER
  16. BUILD.gn
  17. BUILD.IGNORE
  18. DIR_METADATA
  19. MODULE_LICENSE_BSD
  20. NOTICE
  21. OWNERS
  22. PRESUBMIT.cfg
  23. README.md
  24. testrunner.cc
  25. unblocked_terms.txt
README.md

libchrome

Overview

This directory includes the source from Chrome's libbase for use in Chrome OS.

See libchrome.md for more info.