Skip to content

Commit 2a412f1

Browse files
author
lkawka
committed
Apply gemini suggestions
1 parent 55d61c5 commit 2a412f1

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

scripts/checkout_experimental_types.sh

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# Treat unset variables as an error.
55
set -euo pipefail
66

7-
TMP_WORK_DIR="/tmp/experimental_types" # Folder for temporary files.
87
A2A_SPEC_REPO="https://github.com/a2aproject/A2A.git" # URL for the A2A spec repo.
98
A2A_SPEC_BRANCH="main" # Name of the branch with experimental changes.
109
FEATURE_BRANCH="experimental-types" # Name of the feature branch to create.
11-
ROOT_DIR=`pwd`"/.."
10+
ROOT_DIR=$(git rev-parse --show-toplevel)
1211

1312
usage() {
1413
cat <<EOF
@@ -29,9 +28,6 @@ OPTIONS:
2928
-f, --feature-branch Name of the new feature branch to create.
3029
(Default: "$FEATURE_BRANCH")
3130
32-
-t, --tmp-dir Directory for temporary checkout files.
33-
(Default: "$TMP_WORK_DIR")
34-
3531
-h, --help Display this help message and exit.
3632
3733
EXAMPLE:
@@ -74,22 +70,22 @@ while [[ $# -gt 0 ]]; do
7470
esac
7571
done
7672

77-
echo "Creating a temporary \"$TMP_WORK_DIR\" folder for A2A spec repo..."
78-
rm -fR $TMP_WORK_DIR # Remove preexisting files if any exist.
79-
mkdir -p $TMP_WORK_DIR
73+
TMP_WORK_DIR=$(mktemp -d)
74+
echo "Created a temporary working directory: $TMP_WORK_DIR"
75+
trap 'rm -rf -- "$TMP_WORK_DIR"' EXIT
8076
cd $TMP_WORK_DIR
8177

8278
echo "Cloning the \"$A2A_SPEC_REPO\" repository..."
83-
git clone $A2A_SPEC_REPO
84-
cd A2A
79+
git clone $A2A_SPEC_REPO spec_repo
80+
cd spec_repo
8581

86-
echo " Checking out the \"$A2A_SPEC_BRANCH\" branch..."
82+
echo "Checking out the \"$A2A_SPEC_BRANCH\" branch..."
8783
git checkout $A2A_SPEC_BRANCH
8884

8985
echo "Running datamodel-codegen..."
9086
GENERATED_FILE="$ROOT_DIR/src/a2a/types.py"
9187
uv run datamodel-codegen \
92-
--input "$TMP_WORK_DIR/A2A/specification/json/a2a.json" \
88+
--input "$TMP_WORK_DIR/spec_repo/specification/json/a2a.json" \
9389
--input-file-type jsonschema \
9490
--output "$GENERATED_FILE" \
9591
--target-python-version 3.10 \
@@ -117,6 +113,3 @@ cd $ROOT_DIR
117113
git checkout -b "$FEATURE_BRANCH"
118114
git add "$GENERATED_FILE"
119115
git commit -m "Experimental types"
120-
121-
echo "Cleaning up..."
122-
yes | rm -R $TMP_WORK_DIR

0 commit comments

Comments
 (0)