forked from sounddrill31/actions_generate_local_manifests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.sh
33 lines (27 loc) · 1.02 KB
/
remove.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Copyright (C) 2024 Souhrud Reddy
#
# SPDX-License-Identifier: Apache-2.0
#
#!/bin/bash
LINE=$1
TESTING_URL=$2
TESTING_BRANCH=$3
# Extract the path to remove
PATH_TO_REMOVE=$(echo "$LINE" | awk '{print $2}' | tr -d '"')
# Clone the manifest repository if it doesn't exist
if [ ! -d "manifest" ]; then
git clone "$TESTING_URL" -b "$TESTING_BRANCH" manifest
fi
# Find all matches for the path in all manifest files
while IFS= read -r MATCH; do
# Extract the full name from the matched line
FULL_NAME=$(echo "$MATCH" | sed -n 's/.*name="\([^"]*\)".*/\1/p')
if [ -n "$FULL_NAME" ]; then
# Check if there's already a remove-project for this name in any manifest file
if ! grep -r "remove-project.*name=\"$FULL_NAME\"" manifest/ >/dev/null; then
# Add a removal entry to the REMOVE_PROJECTS array only if it's not already marked for removal
REMOVE_PROJECTS[$FULL_NAME]=" <remove-project name=\"$FULL_NAME\" />"
fi
fi
done < <(grep -r "path=\"$PATH_TO_REMOVE\"" manifest/)