Skip to content

Commit 8fce687

Browse files
committed
Push to esp32-arduino-libs
1 parent 3b1b774 commit 8fce687

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

tools/push-to-arduino.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,69 @@ if [ "$AR_HAS_PR" == "0" ]; then
5151
exit 1
5252
fi
5353
fi
54+
55+
#
56+
# esp32-arduino-libs
57+
#
58+
cd "$AR_ROOT"
59+
IDF_LIBS_DIR="$AR_ROOT/../esp32-arduino-libs"
60+
61+
if [ ! -d "$IDF_LIBS_DIR" ]; then
62+
echo "Cloning esp32-arduino-libs..."
63+
git clone "https://github.com/espressif/esp32-arduino-libs.git" "$IDF_LIBS_DIR"
64+
else
65+
echo "Updating esp32-arduino-libs..."
66+
git -C "$IDF_LIBS_DIR" fetch && \
67+
git -C "$IDF_LIBS_DIR" pull --ff-only
68+
fi
69+
if [ $? -ne 0 ]; then exit 1; fi
70+
71+
LIBS_HAS_COMMIT=`git_commit_exists "$IDF_LIBS_DIR" "$AR_NEW_COMMIT_MESSAGE"`
72+
LIBS_HAS_BRANCH=`git_branch_exists "$IDF_LIBS_DIR" "$AR_NEW_BRANCH_NAME"`
73+
74+
if [ "$LIBS_HAS_COMMIT" == "1" ]; then
75+
echo "Commit '$AR_NEW_COMMIT_MESSAGE' in esp32-arduino-libs Already Exists"
76+
mkdir -p dist && echo "Commit '$AR_NEW_COMMIT_MESSAGE' Already Exists" > dist/log.txt
77+
exit 0
78+
fi
79+
80+
if [ "$LIBS_HAS_BRANCH" == "1" ]; then
81+
echo "Branch '$AR_NEW_BRANCH_NAME' Already Exists"
82+
echo "Switching to esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
83+
git -C "$IDF_LIBS_DIR" checkout $AR_NEW_BRANCH_NAME
84+
else
85+
echo "Creating esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
86+
git -C "$IDF_LIBS_DIR" checkout -b $AR_NEW_BRANCH_NAME
87+
fi
88+
if [ $? -ne 0 ]; then
89+
echo "ERROR: Checkout of branch '$AR_NEW_BRANCH_NAME' failed"
90+
exit 1
91+
fi
92+
93+
if [ $LIBS_HAS_COMMIT == "0" ]; then
94+
# make changes to the files
95+
echo "Patching files in esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
96+
rm -rf $IDF_LIBS_DIR/sdk && cp -Rf $AR_TOOLS/sdk $IDF_LIBS_DIR/
97+
98+
cd $IDF_LIBS_DIR
99+
100+
# did any of the files change?
101+
if [ -n "$(git status --porcelain)" ]; then
102+
echo "Pushing changes to esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'..."
103+
git add . && git commit --message "$AR_NEW_COMMIT_MESSAGE" && git push -u origin $AR_NEW_BRANCH_NAME
104+
if [ $? -ne 0 ]; then
105+
echo "ERROR: Pushing to branch '$AR_NEW_BRANCH_NAME' failed"
106+
exit 1
107+
fi
108+
else
109+
echo "No changes in esp32-arduino-libs branch '$AR_NEW_BRANCH_NAME'"
110+
if [ $LIBS_HAS_BRANCH == "0" ]; then
111+
echo "Delete created branch '$AR_NEW_BRANCH_NAME'"
112+
git branch -d $AR_NEW_BRANCH_NAME
113+
fi
114+
exit 0
115+
fi
116+
fi
117+
118+
54119
exit 0

0 commit comments

Comments
 (0)