Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .github/workflows/format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fi

PR_NUMBER="$1"
PATCH_FILE="$2"
TMP_BRANCH="$3"
if [ -z "$PR_NUMBER" ]; then
echo "Please provide a PR link or number. For example: https://github.com/ossrs/ffmpeg-webrtc/pull/20"
exit 1
Expand Down Expand Up @@ -52,7 +53,7 @@ fi

git checkout workflows &&
echo "Switched to workflows branch." &&
git pull
git pull &&
echo "Pulled latest changes from workflows branch."
if [[ $? -ne 0 ]]; then
echo "Failed to switch to workflows branch or pull latest changes."
Expand All @@ -71,7 +72,9 @@ if [[ $? -ne 0 ]]; then
exit 1
fi

TMP_BRANCH=tmp-branch-for-patch-$PR_NUMBER &&
if [[ -z "$TMP_BRANCH" ]]; then
TMP_BRANCH="tmp-branch-for-patch-$PR_NUMBER"
fi &&
if git branch --list "$TMP_BRANCH" | grep -q "^..$TMP_BRANCH$"; then
git branch -D "$TMP_BRANCH"
fi &&
Expand All @@ -90,7 +93,7 @@ if [[ -z "$FIRST_AUTHOR_NAME" || -z "$FIRST_AUTHOR_EMAIL" ]]; then
exit 1
fi

COAUTHORS=$(git log workflows..HEAD --format='Co-authored-by: %an <%ae>' |grep -v "$FIRST_AUTHOR_NAME" | sort -u)
COAUTHORS=$(git log workflows..HEAD --format='Co-authored-by: %an <%ae>' | sort -u)
COAUTHOR_COUNT=$(echo "$COAUTHORS" | wc -l)
if [[ "$COAUTHOR_COUNT" -gt 0 ]]; then
echo "$COAUTHORS"
Expand All @@ -109,14 +112,27 @@ fi
echo "Commit information:"
echo "Author: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
echo "==================================================================="
echo -n -e "$COMMIT_MSG"
echo -e "$COMMIT_MSG"
echo "==================================================================="
echo ""

if [[ $(git config --list --local |grep 'user.name' >/dev/null 2>&1 && echo yes) != "yes" ]]; then
git config --local user.name "$FIRST_AUTHOR_NAME"
fi &&
if [[ $(git config --list --local |grep 'user.email' >/dev/null 2>&1 && echo yes) != "yes" ]]; then
git config --local user.email "$FIRST_AUTHOR_EMAIL"
fi &&
git config --list &&
echo "Set local git user configuration to: $FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>"
if [[ $? -ne 0 ]]; then
echo "Failed to set local git user configuration."
exit 1
fi

git rebase workflows &&
git reset --soft workflows &&
git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -n -e "$COMMIT_MSG")" &&
echo "Squashed commits into a single commit." &&
git commit --author "$FIRST_AUTHOR_NAME <$FIRST_AUTHOR_EMAIL>" -m "$(echo -e "$COMMIT_MSG")" &&
echo "Squashed commits into a single commit."
if [[ $? -ne 0 ]]; then
echo "Failed to rebase or commit changes."
exit 1
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,18 @@ jobs:

PR_NUMBER=${{ github.event.pull_request.number }}
PATCH_FILENAME="whip-patch-$PR_NUMBER-$(date +%s)"
TMP_BRANCH="tmp-branch-for-patch-$PR_NUMBER"
echo "PR ID is ${{ github.event.pull_request.number }}"
echo "Patch file is $PATCH_FILENAME.patch"
echo "Temporary branch is $TMP_BRANCH"

bash .github/workflows/format-patch.sh $PR_NUMBER "$PATCH_FILENAME.patch"
echo "patch_file=$PATCH_FILENAME" >> $GITHUB_OUTPUT
echo "temporary_branch=$TMP_BRANCH" >> $GITHUB_OUTPUT
- name: Show Branch Info
run: git show ${{ steps.format_patch.outputs.temporary_branch }}
- name: Show Patch File
run: cat ${{ steps.format_patch.outputs.patch_file }}.patch
- name: Upload all patch files
uses: actions/upload-artifact@v4
with:
Expand Down