diff options
author | Gurpreet Singh <gurpreetgs@google.com> | 2022-10-19 15:25:49 +0000 |
---|---|---|
committer | Gurpreet Singh <gurpreetgs@google.com> | 2022-10-19 15:25:49 +0000 |
commit | a772ee4cb187e1ddad9bd57a19cf5a82167b73b4 (patch) | |
tree | 3659683d80762bbc9d93dd3cd14cf50cc99b7091 | |
parent | d676cf672ca98f9ae56aa541b1a69bac16657d5e (diff) | |
download | common-a772ee4cb187e1ddad9bd57a19cf5a82167b73b4.tar.gz |
Use fixed timestamps before performing api diff operation.
The api diff files contain the timestamp of files which are being
diffed. This results in different diffs getting generated everytime
even if all the APIs are the same.
In order to generate same diffs, fixed timestamps are assigned to the
files being diffed before the diff operation.
Bug: 238757360
Test: The builds passed and the api diff files contain the fixed
timestamps.
Change-Id: I89f88aa709b5a7a7f52d610b2f8ddf501712e529
-rwxr-xr-x | build/mainline_modules_sdks.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/build/mainline_modules_sdks.py b/build/mainline_modules_sdks.py index 7c9b8531..c1eb02da 100755 --- a/build/mainline_modules_sdks.py +++ b/build/mainline_modules_sdks.py @@ -303,6 +303,11 @@ def set_default_timestamp(base_dir, paths): p = os.path.join(base_dir, path) os.utime(p, (timestamp, timestamp)) +# set the timestamp of the file path to default_zip_time. +def set_default_timestamp_to_file(file_path): + timestamp = default_zip_time.timestamp() + os.utime(file_path, (timestamp, timestamp)) + @dataclasses.dataclass() class SnapshotBuilder: @@ -536,6 +541,8 @@ java_sdk_library_import {{ with zipfile.ZipFile(sdk_zip_file, "r") as zipObj: extracted_current_api = zipObj.extract( member=current_api, path=snapshots_dir) + set_default_timestamp_to_file(extracted_current_api) + set_default_timestamp_to_file(latest_api) # The diff tool has an exit code of 0, 1 or 2 depending on whether # it find no differences, some differences or an error (like missing # file). As 0 or 1 are both valid results this cannot use check=True |