I would like to create an alias in script for creating pull-requests using hub.
I'm planning on creating a function like this.
# PR
function pr --description 'hub pr'
hub pull-request -b $argv[0] -m $argv[1];
end
The -m part can be optional though.
So I can all it like this pr 'branch here' 'message here'
But I get an error saying Array index out of bounds.
function pr -d 'git pull-request' -a branch message
set -q message[1]
and set message -m $message
hub pull-request -b $branch $message
end
Fish arrays start at index 1, so your $argv[0] is wrong here. Use $argv[1] instead of that, and $argv[2] instead of the $argv[1] you currently have.
However, currently any element except 1 will result in an array-index-out-of-bounds error if you try to access it and it isn't set, so you need to check if it is with set -q argv[2].
# PR
function pr --description 'hub pr'
set -l message
if set -q argv[2]
set message -m $argv[2]
end
hub pull-request -b $argv[1] $message;
end
(Also, https://github.com/fish-shell/fish-shell/issues/826 discusses removing index-out-of-bounds errors)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With