Skip to content
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

Update create_pull_request.sh #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 13 additions & 12 deletions scripts/create_pull_request.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ HEAD_BRANCH="head_branch" # The branch you want to merge from
PR_TITLE="Pull Request Title"
PR_BODY="Pull Request Body"

install_tool() {
tool_name=$1

# Install the specified tool if not already installed
if ! command -v $tool_name &> /dev/null; then
echo "$tool_name command-line tool is not installed. Installing..."
sudo apt-get update
sudo apt-get install $tool_name -y
fi
}

# Method 1: Using GitHub API with cURL
create_pull_request_with_curl() {
# Create a pull request using GitHub API
Expand All @@ -30,25 +41,15 @@ create_pull_request_with_curl() {

# Method 2: Using hub command-line tool
create_pull_request_with_hub() {
# Install hub if not already installed
if ! command -v hub &> /dev/null; then
echo "hub command-line tool is not installed. Installing..."
sudo apt-get update
sudo apt-get install hub -y
fi
install_tool "hub"

# Create a pull request using hub
hub pull-request -b "$REPO_OWNER:$BASE_BRANCH" -h "$REPO_OWNER:$HEAD_BRANCH" -m "$PR_TITLE" -m "$PR_BODY"
}

# Method 3: Using gh command-line tool
create_pull_request_with_gh() {
# Install gh if not already installed
if ! command -v gh &> /dev/null; then
echo "gh command-line tool is not installed. Installing..."
sudo apt-get update
sudo apt-get install gh -y
fi
install_tool "gh"

# Create a pull request using gh
gh pr create --base "$BASE_BRANCH" --head "$HEAD_BRANCH" --title "$PR_TITLE" --body "$PR_BODY"
Expand Down