答案 0 :(得分:2)
git提交正在做的是查看每个分支并检查分支与您提交的提交之间的合并(或者如果没有则是HEAD)是否对应于分支之一。
如果匹配,则合并;如果他们不这样做,那就不行了。你可以很容易地在ruby中完成这个循环
repo.branches.each(:local) # look only at local branches
.map { |b|
tgt = b.resolve.target # look at what the branch is pointing to
# and check if the target commit is included in the history of HEAD
merged = repo.merge_base(repo.head.target, tgt) == tgt.oid
[b.name, merged]
} # this will give a list with the name and whether the branch is merged
.keep_if { |name, merged| merged } # keep only the ones which are merged
.map(&:first) # get the name
你可以在第一个区块中有一个merged_list << b.name if merged
,并使其挂起each
,但我喜欢编写数据流。
您还可以根据需要更改是否对分支机构使用:local
,:remote
或两者。您还可以将repo.head.target
更改为您要比较的任何ID。