-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgit-pr
More file actions
executable file
·32 lines (25 loc) · 809 Bytes
/
git-pr
File metadata and controls
executable file
·32 lines (25 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/zsh
## Custom command `git pr`
# Opens your default browser directly to
# create a PR for your current branch
if git status &>/dev/null; then
origin=$(git remote get-url --push origin)
sub_github="github"
sub_gitlab="gitlab"
if [[ "$origin" == *"$sub_github"* ]]; then
git_base="https://github.com"
git_path=${${origin/git@github.com:/}/.git/}
elif [[ "$origin" == *"$sub_gitlab"* ]]; then
git_base="https://gitlab.com"
git_path=${${origin/git@gitlab.com:/}/.git}
else
echo "Unknown git domain..."
exit 1
fi
git_repo_url="${git_base}/${git_path}"
git_branch=$(git branch --show-current)
pr_url="${git_repo_url}/compare/${git_branch}"
open "${pr_url}"
else
echo "This isn't a git repository..."
fi