【发布时间】:2014-11-07 15:00:21
【问题描述】:
【问题讨论】:
【问题讨论】:
git commit 所做的是查看每个分支并检查分支与您给出的提交(或 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。
【讨论】: