Skip to content

address bug with too much in the PRs #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 26, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate Plugin Version
uses: ./
with:
Expand Down
34 changes: 32 additions & 2 deletions bin/validate-plugin-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@ set -euo pipefail
IFS=$'\n\t'

main() {
# Determine the default branch
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
echo "Default branch is $DEFAULT_BRANCH"

# Check out the specified branch if $BRANCH is set and not already on it
if [[ -n "${BRANCH:-}" && "$(git rev-parse --abbrev-ref HEAD)" != "$BRANCH" ]]; then
echo "Checking if branch $BRANCH exists."
if ! git show-ref --verify --quiet "refs/heads/$BRANCH"; then
if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then
echo "Branch '$BRANCH' exists on remote. Checking out from remote."
git checkout -b "$BRANCH" "origin/$BRANCH"
else
echo "Error: Branch '$BRANCH' does not exist."
exit 1
fi
else
echo "Checking out branch $BRANCH"
git checkout "$BRANCH"
fi
fi

# If $PLUGIN_PATH is defined, echo it.
if [[ -n "${PLUGIN_PATH:-}" ]]; then
PLUGIN_PATH=${WORKFLOW_PATH}/${PLUGIN_PATH}
PLUGIN_PATH=${WORKFLOW_PATH}/${PLUGIN_PATH}
echo "Plugin path: $PLUGIN_PATH"
else
local PLUGIN_PATH
Expand Down Expand Up @@ -89,6 +110,11 @@ main() {
full_path="${PLUGIN_PATH}/${trimmed_filename}"
if [[ -f "$full_path" ]]; then
git add "$full_path"
# If we're dry-running, output the contents of the changed files.
if [[ "${DRY_RUN}" == "true" ]]; then
echo -e "\n"
cat "$full_path"
fi
fi
done

Expand All @@ -108,7 +134,11 @@ main() {
git commit -m "Update Tested Up To version to $CURRENT_WP_VERSION"
git push origin "$BRANCH_NAME"

gh pr create --title "Update Tested Up To version to $CURRENT_WP_VERSION" --body "This pull request updates the \"Tested up to\" version in specified files (${FILENAMES}) to match the current WordPress version $CURRENT_WP_VERSION." --base "$BRANCH"
# Determine the base branch for the PR
BASE_BRANCH="${BRANCH:-$DEFAULT_BRANCH}"

echo "Creating a pull request with base branch $BASE_BRANCH."
gh pr create --title "Update Tested Up To version to $CURRENT_WP_VERSION" --body "This pull request updates the \"Tested up to\" version in specified files (${FILENAMES}) to match the current WordPress version $CURRENT_WP_VERSION." --base "$BASE_BRANCH"
}

main