For our buildbot, I want to display the most recently-updated active (non-released) branches. Let's say I have a master
branch, as well as the following, from oldest to newest commit:
branch1
(not merged into master
)branch2
(merged)branch3
(not merged)I am able to get each of these lists separately... e.g. to get all the branches not merged into master
:
$ git branch -r --no-merged origin/master
origin/branch1
origin/branch3
Or to get the top fifteen branches, ordered by most recent commit (via https://coderwall.com/p/ndinba):
$ git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short)' --count=15 refs/remotes/origin/
2013-03-22 origin/branch3
2013-03-22 origin/branch2
2013-03-22 origin/master
2013-03-22 origin/branch1
So I basically want that second list, minus branch2
(with or without master
). Hope that makes sense?
Can't you just grep out branch2?
Basically, something like:
for branch in `git branch -r --no-merged origin/master`; do git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short)' --count=15 refs/remotes/origin/ | grep $branch; done;
That worked for me given your sample output.
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