I'm trying to make a git alias to approve pull request(s) on GitHub. The main feature of this alias is ability to octopus merge multiple pull requests.
What I got so far (.gitconfig):
[alias]
approve = "!f() { git fetch origin $(echo $@ | xargs -n 1 | xargs -I {} echo refs/pull/{}/head:gh-{} ) && git merge $(echo $@ | xargs -n 1 | xargs -I {} echo gh-{}) --edit --log;}; f"
It works as expected, however I want to know if it is possible to simplify arguments processing:
$(echo $@ | xargs -n 1 | xargs -I {} echo refs/pull/{}/head:gh-{} )
and
$(echo $@ | xargs -n 1 | xargs -I {} echo gh-{})
Usage
$ git approve 1 2 3 # to approve pull requests #1, #2 and #3
Output
SHA-1: XXXX
* Merge branches 'gh-1' and 'gh-2'
* gh-1:
fix 1
* gh-2:
fix 2