File tree Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ concurrency:
1010jobs :
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
Original file line number Diff line number Diff line change 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
3138here=${0%/* }
@@ -83,8 +90,15 @@ if [[ -z "$DOCKER_DEFAULT_PLATFORM" && "$(uname -sm)" == "Darwin arm64" ]]; then
8390fi
8491
8592if [[ -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
88102fi
89103
90104if [[ $pull_image -eq 1 ]]; then
Original file line number Diff line number Diff line change @@ -19,7 +19,19 @@ set -x
1919
2020branch_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+
2537git push
You can’t perform that action at this time.
0 commit comments