Add git pull request script
This commit is contained in:
parent
9de44888ba
commit
fd2c0c1421
2 changed files with 37 additions and 0 deletions
34
.local/bin/git-pr
Executable file
34
.local/bin/git-pr
Executable file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the current branch name
|
||||||
|
CURRENT_BRANCH=$(git branch --show-current)
|
||||||
|
|
||||||
|
# Get the default branch (usually main or master)
|
||||||
|
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
|
||||||
|
|
||||||
|
# Push the current branch to origin
|
||||||
|
echo "Pushing $CURRENT_BRANCH to origin..."
|
||||||
|
git push -u origin "$CURRENT_BRANCH"
|
||||||
|
|
||||||
|
# Check if push was successful
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to push branch"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the last commit's first line (title)
|
||||||
|
PR_TITLE=$(git log -1 --pretty=format:%s)
|
||||||
|
|
||||||
|
# Get the last commit's body (everything after the first line)
|
||||||
|
PR_BODY=$(git log -1 --pretty=format:%b)
|
||||||
|
|
||||||
|
# Create PR using the commit message
|
||||||
|
echo "Creating PR..."
|
||||||
|
echo "Title: $PR_TITLE"
|
||||||
|
echo "Body: $PR_BODY"
|
||||||
|
|
||||||
|
gh pr create \
|
||||||
|
--base "$DEFAULT_BRANCH" \
|
||||||
|
--head "$CURRENT_BRANCH" \
|
||||||
|
--title "$PR_TITLE" \
|
||||||
|
--body "$PR_BODY"
|
||||||
|
|
@ -34,3 +34,6 @@ https://github.com/tmux-plugins/tpm
|
||||||
|
|
||||||
## Nvim uses vim-plug
|
## Nvim uses vim-plug
|
||||||
https://github.com/junegunn/vim-plug
|
https://github.com/junegunn/vim-plug
|
||||||
|
|
||||||
|
## Shell scripts
|
||||||
|
The repository also contains a couple of helper shell scripts located in .local/bin
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue