Adding usage to commit message and METADATA of projects
Test: TreeHugger
Change-Id: I510495993dd31e61b6b9e6a42cc49f65ba7443ab
diff --git a/external_updater.py b/external_updater.py
index e1b19ec..e418517 100644
--- a/external_updater.py
+++ b/external_updater.py
@@ -26,7 +26,7 @@
import json
import os
import sys
-import subprocess
+import textwrap
import time
from typing import Dict, Iterator, List, Union, Tuple, Type
from pathlib import Path
@@ -113,8 +113,14 @@
return
rel_proj_path = fileutils.get_relative_project_path(full_path)
- msg = 'Upgrade {} to {}\n\nTest: make\n'.format(
- rel_proj_path, updater.latest_version)
+ msg = textwrap.dedent(f"""\
+ Upgrade {rel_proj_path} to {updater.latest_version}
+
+ This project was upgraded with external_updater.
+ Usage: tools/external_updater/updater.sh update {rel_proj_path}
+ For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
+ Test: TreeHugger""")
git_utils.remove_gitmodules(full_path)
git_utils.add_file(full_path, '*')
git_utils.commit(full_path, msg)
diff --git a/fileutils.py b/fileutils.py
index 17202c8..861e4a6 100644
--- a/fileutils.py
+++ b/fileutils.py
@@ -85,12 +85,19 @@
date.year = now.year
date.month = now.month
date.day = now.day
- text_metadata = text_format.MessageToString(metadata)
+ usage_hint = textwrap.dedent(f"""\
+ # This project was upgraded with external_updater.
+ # Usage: tools/external_updater/updater.sh update {metadata.name}
+ # For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
+ """)
+ text_metadata = usage_hint + text_format.MessageToString(metadata)
with get_metadata_path(proj_path).open('w') as metadata_file:
if metadata.third_party.license_type == metadata_pb2.LicenseType.BY_EXCEPTION_ONLY:
metadata_file.write(textwrap.dedent("""\
- # *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
- # CONSULT THE OWNERS AND [email protected] BEFORE
- # DEPENDING ON IT IN YOUR PROJECT. ***
+ # THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
+ # CONSULT THE OWNERS AND [email protected] BEFORE
+ # DEPENDING ON IT IN YOUR PROJECT.
+
"""))
metadata_file.write(text_metadata)