Skip to content

Commit c05da7f

Browse files
[SL-ONLY] Update restyle scripts to work with matter_sdk structure (#644)
1 parent 80ae5fe commit c05da7f

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

.github/workflows/restyled.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ concurrency:
1010
jobs:
1111
restyled:
1212
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
1318
steps:
1419
- name: Checkout
1520
uses: actions/checkout@v5

scripts/helpers/restyle-diff.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@
2323
# Usage:
2424
# restyle-diff.sh [-d] [-p] [ref]
2525
#
26-
# if unspecified, ref defaults to upstream/master (or master)
27-
# -d sets container's log level to DEBUG, if unspecified the default log level will remain (info level)
28-
# -p pulls the Docker image before running the restyle paths
26+
# Arguments:
27+
# ref - Git reference to compare against (optional)
28+
#
29+
# Options:
30+
# -d - Sets container's log level to DEBUG, if unspecified, the default log level will remain (info level)
31+
# -p - Pulls the Docker image before running the restyle paths
32+
#
33+
# Reference Selection (when ref is not specified):
34+
# - If origin is https://github.com/SiliconLabsSoftware/matter_sdk.git (main repo): uses origin/main
35+
# - Otherwise (fork setup): uses upstream/main if upstream remote exists, otherwise defaults to main
2936
#
3037

3138
here=${0%/*}
@@ -83,8 +90,15 @@ if [[ -z "$DOCKER_DEFAULT_PLATFORM" && "$(uname -sm)" == "Darwin arm64" ]]; then
8390
fi
8491

8592
if [[ -z "$ref" ]]; then
86-
ref="master"
87-
git remote | grep -qxF upstream && ref="upstream/master"
93+
# Check if origin points to the main repo
94+
origin_url=$(git remote get-url origin 2>/dev/null || echo "")
95+
if [[ "$origin_url" == "https://github.com/SiliconLabsSoftware/matter_sdk.git" ]]; then
96+
ref="origin/main"
97+
else
98+
# Assume fork setup - use upstream/main if available, otherwise local main
99+
ref="main"
100+
git remote | grep -qxF upstream && ref="upstream/main"
101+
fi
88102
fi
89103

90104
if [[ $pull_image -eq 1 ]]; then

scripts/helpers/restyle_merge.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ set -x
1919

2020
branch_name=$(git branch | grep "^*" | awk '{print $2}')
2121

22-
git remote add upstream https://github.com/project-chip/connectedhomeip.git
23-
git fetch upstream restyled/"$branch_name"
24-
git merge --ff-only FETCH_HEAD
22+
# Check if origin points to the main repo
23+
origin_url=$(git remote get-url origin 2>/dev/null || echo "")
24+
if [[ "$origin_url" == "https://github.com/SiliconLabsSoftware/matter_sdk.git" ]]; then
25+
# Main repo setup - fetch restyled branch from origin
26+
git fetch origin restyled/"$branch_name"
27+
git merge --ff-only FETCH_HEAD
28+
else
29+
# Fork setup - ensure upstream remote exists and use it
30+
if ! git remote | grep -qxF upstream; then
31+
git remote add upstream https://github.com/SiliconLabsSoftware/matter_sdk.git
32+
fi
33+
git fetch upstream restyled/"$branch_name"
34+
git merge --ff-only FETCH_HEAD
35+
fi
36+
2537
git push

0 commit comments

Comments
 (0)