config/fish/functions/pull_request.fish

18 lines
851 B
Fish

function pull_request --argument-names target_branch source_branch
if test -z "$target_branch"
set target_branch (git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
echo "Using default branch as target: "$target_branch
end
if test -z "$source_branch"
set source_branch (git branch --show-current)
echo "Using current branch as source: "$source_branch
end
# Format: ssh://git@git.source.akamai.com:7999/<project>/<repo>.git
set --local origin (git remote get-url origin)
set --local project (string split -r -m2 '/' $origin)[-2]
set --local repo (basename -s .git $origin)
open "https://git.source.akamai.com/projects/"$project"/repos/"$repo"/compare/commits?sourceBranch=refs%2Fheads%2F"$source_branch"&targetBranch=refs%2Fheads%2F"$target_branch
end