Skip to content

Commit

Permalink
use github user name if available
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 18, 2023
1 parent 6a07a6a commit 49f67c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ The cherry-picker script is configured to use `v1` as the base branch and `maste
It will create a new checkout in a temp dir, create a new branch, perform the cherry-pick, and then
prompt before creating a PR to the target branch.

If you set your GitHub username, it will create the branch on your fork,

```bash
git config --global github.user <github_handle>
```

## Testing / Development

The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `make` (on Windows, run `nmake`). This will run coverage, run go-lint, run go-vet, and build the examples.
Expand Down
15 changes: 11 additions & 4 deletions etc/cherry-picker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@ git cherry-pick -x $sha

old_title=$(git --no-pager log -1 --pretty=%B | head -n 1)
ticket=$(echo $old_title | sed -r 's/([A-Z]+-[0-9]+).*/\1/')
echo "ticket $ticket"
text=$(echo $old_title | sed -r 's/([A-Z]+-[0-9]+) (.*) \(#[0-9]*\)/\2/')
echo "text $text"
pr_number=$(echo $old_title| sed -r 's/.*(#[0-9]*)\)/\1/')
echo "pr number: $pr_number"
user=$(git config github.user)

if [ -n "$user" ]; then
head="$user:$branch"
else
head="$origin:$branch"
fi

title="$ticket [$target] $text"
body="Cherry-pick of $pr_number from $base to $target"

echo
echo "Creating PR..."
echo "Title: $title"
echo "Body: $body"
echo "Base: $base"
echo "Head: $head"
echo

read -p 'Push changes? (Y/n) ' choice
if [[ "$choice" == "Y" || "$choice" == "y" || -z "$choice" ]]; then
gh pr create --title "$title" --base $target --body "$body"
gh pr create --title "$title" --base $target --head $head --body "$body"
fi

0 comments on commit 49f67c2

Please sign in to comment.