From fdc6c42374ff413cd27011826b76973d122bccb9 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Wed, 19 Nov 2025 15:31:46 -0800 Subject: [PATCH 1/4] add delete checker --- .github/workflows/snippet-deletes.yml | 18 +++++++++ delete-check.sh | 57 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/snippet-deletes.yml create mode 100755 delete-check.sh diff --git a/.github/workflows/snippet-deletes.yml b/.github/workflows/snippet-deletes.yml new file mode 100644 index 0000000..cb906fe --- /dev/null +++ b/.github/workflows/snippet-deletes.yml @@ -0,0 +1,18 @@ +on: + pull_request: + paths: + - '**/*.h' + - '**/*.m' + - '**/*.swift' +name: Check for snippet deletes +jobs: + deletes-check: + name: deletes-check + runs-on: macOS-latest + steps: + - name: Checkout + uses: actions/checkout@master + run: git fetch origin main + - name: Check for deleted start or end tags + run: bash delete-check.sh + continue-on-error: true diff --git a/delete-check.sh b/delete-check.sh new file mode 100755 index 0000000..c97b2ef --- /dev/null +++ b/delete-check.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Checks if any includecode tags were removed. + +# Default state for the acknowledge flag +ACKNOWLEDGE=false + +# Loop through arguments to check for the flag +for arg in "$@" +do + if [ "$arg" == "--acknowledge" ]; then + ACKNOWLEDGE=true + fi +done + +# Define the target branch (you can change this to origin/main if needed) +TARGET_BRANCH="master" + +# Check if the target branch exists +if ! git rev-parse --verify "$TARGET_BRANCH" >/dev/null 2>&1; then + echo "Error: Branch '$TARGET_BRANCH' not found." + exit 1 +fi + +# Run git diff to find deleted lines matching the pattern +# ^- : Matches lines starting with a minus (deleted lines in diff) +# .* : Matches any character sequence +# // \[ : Matches the literal string "// [" +# (START|END) : Matches either START or END +MATCHES=$(git diff "$TARGET_BRANCH" | grep -E "^-.*// \[(START|END)") + +# If matches are found +if [ -n "$MATCHES" ]; then + echo "---------------------------------------------------------" + echo "WARNING: Snippet region markers found in deleted lines:" + echo "---------------------------------------------------------" + echo "$MATCHES" + echo "---------------------------------------------------------" + echo "Be sure to update devsite so this PR does not break docs." + echo "---------------------------------------------------------" + + # Running this check would require generating a GH token to read + # the PR description, which isn't really worth it. The entire + # check can be run as continue-on-error in GHA instead. + # if [ "$ACKNOWLEDGE" = true ]; then + # echo "Acknowledge flag detected. Exiting with success (0)." + # exit 0 + # else + # echo "ERROR: You are deleting region markers." + # echo "Run with --acknowledge to bypass this check." + # exit 1 + # fi + + exit 1 +fi + +# If no matches found, exit successfully +exit 0 \ No newline at end of file From 1481aac34d172e3d30c5656178b9961fb95b16f9 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Wed, 19 Nov 2025 15:32:14 -0800 Subject: [PATCH 2/4] test deleting a snippet --- .../AppAttestProviderFactories.m | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/appcheck/AppCheckSnippetsObjC/AppAttestProviderFactories.m b/appcheck/AppCheckSnippetsObjC/AppAttestProviderFactories.m index 2d892ab..fb864fe 100644 --- a/appcheck/AppCheckSnippetsObjC/AppAttestProviderFactories.m +++ b/appcheck/AppCheckSnippetsObjC/AppAttestProviderFactories.m @@ -30,19 +30,4 @@ @implementation YourSimpleAppCheckProviderFactory @end // [END appcheck_simple_appattest_factory] -// [START appcheck_appattest_factory] -@interface YourAppCheckProviderFactory : NSObject -@end - -@implementation YourAppCheckProviderFactory - -- (nullable id)createProviderWithApp:(nonnull FIRApp *)app { - if (@available(iOS 14.0, *)) { - return [[FIRAppAttestProvider alloc] initWithApp:app]; - } else { - return [[FIRDeviceCheckProvider alloc] initWithApp:app]; - } -} -@end -// [START appcheck_appattest_factory] From 0455c3f1249478aa63a80a2c14ed58f48ef3ef02 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Wed, 19 Nov 2025 15:33:30 -0800 Subject: [PATCH 3/4] eof newline --- delete-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/delete-check.sh b/delete-check.sh index c97b2ef..f2274b9 100755 --- a/delete-check.sh +++ b/delete-check.sh @@ -54,4 +54,4 @@ if [ -n "$MATCHES" ]; then fi # If no matches found, exit successfully -exit 0 \ No newline at end of file +exit 0 From 910e27c48c2913bc7e99b1dd97e9b172ef18d8ad Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Wed, 19 Nov 2025 15:41:01 -0800 Subject: [PATCH 4/4] remove paths --- .github/workflows/snippet-deletes.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/snippet-deletes.yml b/.github/workflows/snippet-deletes.yml index cb906fe..7f1b99a 100644 --- a/.github/workflows/snippet-deletes.yml +++ b/.github/workflows/snippet-deletes.yml @@ -1,9 +1,5 @@ -on: - pull_request: - paths: - - '**/*.h' - - '**/*.m' - - '**/*.swift' +on: pull_request + name: Check for snippet deletes jobs: deletes-check: