diff --git a/.local/bin/git-pr b/.local/bin/git-pr new file mode 100755 index 0000000..68ab780 --- /dev/null +++ b/.local/bin/git-pr @@ -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" diff --git a/README.md b/README.md index 80c267b..0fa5949 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,6 @@ https://github.com/tmux-plugins/tpm ## Nvim uses vim-plug https://github.com/junegunn/vim-plug + +## Shell scripts +The repository also contains a couple of helper shell scripts located in .local/bin