From 9f87cfb9fe829a9c83a3ac6393ae3de9204aedee Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 18:29:13 -0800 Subject: [PATCH 1/3] Add copyright line to iOS headers --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index e748af08c8..1f9fe8b0b5 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -109,7 +109,7 @@ jobs: # Each file in this directory matches a file in the Analytics iOS SDK. cp -vf "${podtmp}/${header_dir}/${ios_header}" . # Add a note to each file about its source. - sed -i~ 's|^/// @file|\n// Copied from Firebase Analytics iOS SDK '"${analytics_version}"'.\n\n/// @file|' "${ios_header}" + sed -i~ 's|^/// @file|// Copyright '"$(date +%Y)"' Google LLC\n\n// Copied from Firebase Analytics iOS SDK '"${analytics_version}"'.\n\n/// @file|' "${ios_header}" rm -f "${ios_header}~" # remove backup file that sed generated python ../../scripts/format_code.py --f "${ios_header}" done From c8309eef00c3981cace34f9d94303c8db1dd97bc Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 18:36:18 -0800 Subject: [PATCH 2/3] Make copyright conditional to whether the file already has one. --- .github/workflows/update-dependencies.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 1f9fe8b0b5..cdd9b102b7 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -108,8 +108,14 @@ jobs: for ios_header in *.h; do # Each file in this directory matches a file in the Analytics iOS SDK. cp -vf "${podtmp}/${header_dir}/${ios_header}" . + # If the file doesn't have a Google copyright, add one. + if ! grep -q '^// Copyright ' "${ios_header}"; then + copyright_line="// Copyright $(date +%Y) Google LLC\n" + else + copyright_line= + fi # Add a note to each file about its source. - sed -i~ 's|^/// @file|// Copyright '"$(date +%Y)"' Google LLC\n\n// Copied from Firebase Analytics iOS SDK '"${analytics_version}"'.\n\n/// @file|' "${ios_header}" + sed -i~ "s|^/// @file|${copyright_line}\n// Copied from Firebase Analytics iOS SDK ${analytics_version}.\n\n/// @file|" "${ios_header}" rm -f "${ios_header}~" # remove backup file that sed generated python ../../scripts/format_code.py --f "${ios_header}" done From 862b38be528383c733846e1fad72bd9d34672711 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 18:38:11 -0800 Subject: [PATCH 3/3] Fix regex --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index cdd9b102b7..6200df50d6 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -109,7 +109,7 @@ jobs: # Each file in this directory matches a file in the Analytics iOS SDK. cp -vf "${podtmp}/${header_dir}/${ios_header}" . # If the file doesn't have a Google copyright, add one. - if ! grep -q '^// Copyright ' "${ios_header}"; then + if ! grep -q "^// Copyright [0-9]* Google LLC" "${ios_header}"; then copyright_line="// Copyright $(date +%Y) Google LLC\n" else copyright_line=